mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-09-05 01:07:39 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5af1e8a17 | ||
|
|
fab7998e22 | ||
|
|
4a4db6851e | ||
|
|
870973e7f3 |
@@ -36,13 +36,13 @@
|
|||||||
"react-dom": "^18.3.1",
|
"react-dom": "^18.3.1",
|
||||||
"react-gtm-module": "^2.0.11",
|
"react-gtm-module": "^2.0.11",
|
||||||
"react-helmet": "^6.1.0",
|
"react-helmet": "^6.1.0",
|
||||||
"react-i18next": "^15.7.3",
|
"react-i18next": "^15.7.4",
|
||||||
"react-konva": "^18.2.12",
|
"react-konva": "^18.2.12",
|
||||||
"react-pdf": "^9.2.1",
|
"react-pdf": "^9.2.1",
|
||||||
"react-quill-new": "^3.6.0",
|
"react-quill-new": "^3.6.0",
|
||||||
"react-redux": "^9.2.0",
|
"react-redux": "^9.2.0",
|
||||||
"react-rnd": "^10.5.2",
|
"react-rnd": "^10.5.2",
|
||||||
"react-router": "^7.9.1",
|
"react-router": "^7.9.3",
|
||||||
"react-scrollbars-custom": "^4.1.1",
|
"react-scrollbars-custom": "^4.1.1",
|
||||||
"react-select": "^5.10.2",
|
"react-select": "^5.10.2",
|
||||||
"react-signature-canvas": "^1.1.0-alpha.2",
|
"react-signature-canvas": "^1.1.0-alpha.2",
|
||||||
|
|||||||
@@ -165,7 +165,8 @@
|
|||||||
"daily-mail-quota": "Tägliches E-Mail-Kontingent",
|
"daily-mail-quota": "Tägliches E-Mail-Kontingent",
|
||||||
"Save as template": "Als Vorlage speichern",
|
"Save as template": "Als Vorlage speichern",
|
||||||
"Fix & resend": "Korrigieren und erneut senden",
|
"Fix & resend": "Korrigieren und erneut senden",
|
||||||
"Kiosk Mode": "Kiosk Modus"
|
"Kiosk Mode": "Kiosk Modus",
|
||||||
|
"Reset password": "Passwort zurücksetzen"
|
||||||
},
|
},
|
||||||
"report-heading": {
|
"report-heading": {
|
||||||
"Sr.No": "Nr.",
|
"Sr.No": "Nr.",
|
||||||
@@ -1230,5 +1231,16 @@
|
|||||||
"save-as-template-msg": "Speichern Sie dieses Dokument als wiederverwendbare Vorlage, die Sie für zukünftige Dokumente erneut nutzen können.",
|
"save-as-template-msg": "Speichern Sie dieses Dokument als wiederverwendbare Vorlage, die Sie für zukünftige Dokumente erneut nutzen können.",
|
||||||
"public-credit-alert": "Das Signieren über diesen Link verbraucht Ihre kostenlosen E-Mail-Credits. Als kostenloser Nutzer erhalten Sie 15 E-Mail-Credits pro Monat, um zu verhindern, dass Spammer unsere Systeme missbrauchen. Um höhere Limits und ununterbrochenen Zugriff zu genießen, abonnieren Sie die <1>OpenSign™-Bezahlpläne.</1>",
|
"public-credit-alert": "Das Signieren über diesen Link verbraucht Ihre kostenlosen E-Mail-Credits. Als kostenloser Nutzer erhalten Sie 15 E-Mail-Credits pro Monat, um zu verhindern, dass Spammer unsere Systeme missbrauchen. Um höhere Limits und ununterbrochenen Zugriff zu genießen, abonnieren Sie die <1>OpenSign™-Bezahlpläne.</1>",
|
||||||
"know-more-about": "Mehr erfahren über",
|
"know-more-about": "Mehr erfahren über",
|
||||||
"free-unlimited-signatures": "Kostenlose unbegrenzte Signaturen"
|
"free-unlimited-signatures": "Kostenlose unbegrenzte Signaturen",
|
||||||
|
"email-quota-updated": "Tägliches E-Mail-Kontingent erfolgreich aktualisiert.",
|
||||||
|
"password-has-been-reset": "Passwort wurde zurückgesetzt.",
|
||||||
|
"Unauthorized to reset your own password.": "Nicht berechtigt, Ihr eigenes Passwort zurückzusetzen.",
|
||||||
|
"User not found or not allowed.": "Benutzer nicht gefunden oder nicht erlaubt.",
|
||||||
|
"User not found.": "Benutzer nicht gefunden.",
|
||||||
|
"Admin user tenant not found.": "Admin-Benutzer-Tenant nicht gefunden.",
|
||||||
|
"User is not authenticated.": "Benutzer ist nicht authentifiziert.",
|
||||||
|
"Please provide required parameters.": "Bitte geben Sie die erforderlichen Parameter an.",
|
||||||
|
"reset-password": "Benutzerpasswort zurücksetzen",
|
||||||
|
"enter-strong-password": "Geben Sie ein sicheres Passwort ein oder generieren Sie eines automatisch.",
|
||||||
|
"autogenerate": "Automatisch generieren"
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,8 @@
|
|||||||
"daily-mail-quota": "Daily Email Quota",
|
"daily-mail-quota": "Daily Email Quota",
|
||||||
"Save as template": "Save as template",
|
"Save as template": "Save as template",
|
||||||
"Fix & resend": "Fix & Resend",
|
"Fix & resend": "Fix & Resend",
|
||||||
"Kiosk Mode": "Kiosk Mode"
|
"Kiosk Mode": "Kiosk Mode",
|
||||||
|
"Reset password": "Reset password"
|
||||||
},
|
},
|
||||||
"report-heading": {
|
"report-heading": {
|
||||||
"Sr.No": "Sr.No",
|
"Sr.No": "Sr.No",
|
||||||
@@ -1231,5 +1232,16 @@
|
|||||||
"save-as-template-msg": "Save this document as a reusable template that you can use again for future documents.",
|
"save-as-template-msg": "Save this document as a reusable template that you can use again for future documents.",
|
||||||
"public-credit-alert": "Signing through this link consumes your free email credits. As a Free user, you are allotted 15 email credits per month to prevent spammers from abusing our systems. To enjoy higher limits and uninterrupted access, Subscribe to <1>OpenSign™ Paid plans.</1>",
|
"public-credit-alert": "Signing through this link consumes your free email credits. As a Free user, you are allotted 15 email credits per month to prevent spammers from abusing our systems. To enjoy higher limits and uninterrupted access, Subscribe to <1>OpenSign™ Paid plans.</1>",
|
||||||
"know-more-about": "Know more about",
|
"know-more-about": "Know more about",
|
||||||
"free-unlimited-signatures": "Free Unlimited Signatures"
|
"free-unlimited-signatures": "Free Unlimited Signatures",
|
||||||
|
"email-quota-updated": "Daily email quota updated successfully.",
|
||||||
|
"password-has-been-reset": "Password has been reset.",
|
||||||
|
"Unauthorized to reset your own password.": "Unauthorized to reset your own password.",
|
||||||
|
"User not found or not allowed.": "User not found or not allowed.",
|
||||||
|
"User not found.": "User not found.",
|
||||||
|
"Admin user tenant not found.": "Admin user tenant not found.",
|
||||||
|
"User is not authenticated.": "User is not authenticated.",
|
||||||
|
"Please provide required parameters.": "Please provide required parameters.",
|
||||||
|
"reset-password": "Reset User Password",
|
||||||
|
"enter-strong-password": "Enter a strong password or auto-generate one.",
|
||||||
|
"autogenerate": "Autogenerate"
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,8 @@
|
|||||||
"daily-mail-quota": "Cuota diaria de correos electrónicos",
|
"daily-mail-quota": "Cuota diaria de correos electrónicos",
|
||||||
"Save as template": "Guardar como plantilla",
|
"Save as template": "Guardar como plantilla",
|
||||||
"Fix & resend": "Corregir y reenviar",
|
"Fix & resend": "Corregir y reenviar",
|
||||||
"Kiosk Mode": "Modo Kiosco"
|
"Kiosk Mode": "Modo Kiosco",
|
||||||
|
"Reset password": "Restablecer contraseña"
|
||||||
},
|
},
|
||||||
"report-heading": {
|
"report-heading": {
|
||||||
"Sr.No": "Nº",
|
"Sr.No": "Nº",
|
||||||
@@ -1231,5 +1232,16 @@
|
|||||||
"save-as-template-msg": "Guarde este documento como una plantilla reutilizable que podrá usar nuevamente para futuros documentos.",
|
"save-as-template-msg": "Guarde este documento como una plantilla reutilizable que podrá usar nuevamente para futuros documentos.",
|
||||||
"public-credit-alert": "Firmar a través de este enlace consumirá sus créditos de correo electrónico gratuitos. Como usuario gratuito, se le asignan 15 créditos de correo electrónico por mes para evitar que los spammers abusen de nuestros sistemas. Para disfrutar de límites más altos y acceso ininterrumpido, suscríbase a los planes de pago de <1>OpenSign™.</1>",
|
"public-credit-alert": "Firmar a través de este enlace consumirá sus créditos de correo electrónico gratuitos. Como usuario gratuito, se le asignan 15 créditos de correo electrónico por mes para evitar que los spammers abusen de nuestros sistemas. Para disfrutar de límites más altos y acceso ininterrumpido, suscríbase a los planes de pago de <1>OpenSign™.</1>",
|
||||||
"know-more-about": "Saber más sobre",
|
"know-more-about": "Saber más sobre",
|
||||||
"free-unlimited-signatures": "¿Firmas ilimitadas gratis"
|
"free-unlimited-signatures": "¿Firmas ilimitadas gratis",
|
||||||
|
"email-quota-updated": "La cuota diaria de correos se actualizó correctamente.",
|
||||||
|
"password-has-been-reset": "La contraseña ha sido restablecida.",
|
||||||
|
"Unauthorized to reset your own password.": "No está autorizado para restablecer su propia contraseña.",
|
||||||
|
"User not found or not allowed.": "Usuario no encontrado o no autorizado.",
|
||||||
|
"User not found.": "Usuario no encontrado.",
|
||||||
|
"Admin user tenant not found.": "Inquilino de usuario administrador no encontrado.",
|
||||||
|
"User is not authenticated.": "El usuario no está autenticado.",
|
||||||
|
"Please provide required parameters.": "Por favor, proporcione los parámetros requeridos.",
|
||||||
|
"reset-password": "Restablecer contraseña de usuario",
|
||||||
|
"enter-strong-password": "Ingrese una contraseña segura o genere una automáticamente.",
|
||||||
|
"autogenerate": "Generar automáticamente"
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,8 @@
|
|||||||
"daily-mail-quota": "Quota d'e-mails quotidien",
|
"daily-mail-quota": "Quota d'e-mails quotidien",
|
||||||
"Save as template": "Enregistrer comme modèle",
|
"Save as template": "Enregistrer comme modèle",
|
||||||
"Fix & resend": "Corriger et renvoyer",
|
"Fix & resend": "Corriger et renvoyer",
|
||||||
"Kiosk Mode": "Mode Kiosque"
|
"Kiosk Mode": "Mode Kiosque",
|
||||||
|
"Reset password": "Réinitialiser le mot de passe"
|
||||||
},
|
},
|
||||||
"report-help": {
|
"report-help": {
|
||||||
"Draft Documents": "Il s'agit de documents que vous avez commencés mais que vous n'avez pas finalisés pour envoi.",
|
"Draft Documents": "Il s'agit de documents que vous avez commencés mais que vous n'avez pas finalisés pour envoi.",
|
||||||
@@ -426,7 +427,7 @@
|
|||||||
"initial-alert": "Mon initiale est introuvable",
|
"initial-alert": "Mon initiale est introuvable",
|
||||||
"copy-title": "Copier le widget vers",
|
"copy-title": "Copier le widget vers",
|
||||||
"contact-delete-alert": "Êtes-vous sûr de vouloir supprimer ce contact ?",
|
"contact-delete-alert": "Êtes-vous sûr de vouloir supprimer ce contact ?",
|
||||||
"reset-password": "Le lien de réinitialisation du mot de passe a été envoyé à votre identifiant de messagerie",
|
"reset-password-alert-1": "Le lien de réinitialisation du mot de passe a été envoyé à votre identifiant de messagerie",
|
||||||
"reset-password-alert-2": "Veuillez configurer l'adaptateur de messagerie",
|
"reset-password-alert-2": "Veuillez configurer l'adaptateur de messagerie",
|
||||||
"reset-password-alert-3": "Réinitialisez votre mot de passe",
|
"reset-password-alert-3": "Réinitialisez votre mot de passe",
|
||||||
"faild-animation": "Échec du chargement de l'animation",
|
"faild-animation": "Échec du chargement de l'animation",
|
||||||
@@ -1230,5 +1231,16 @@
|
|||||||
"save-as-template-msg": "Enregistrez ce document comme modèle réutilisable que vous pourrez utiliser à nouveau pour de futurs documents.",
|
"save-as-template-msg": "Enregistrez ce document comme modèle réutilisable que vous pourrez utiliser à nouveau pour de futurs documents.",
|
||||||
"public-credit-alert": "Signer via ce lien consomme vos crédits e-mail gratuits. En tant qu'utilisateur gratuit, vous disposez de 15 crédits e-mail par mois afin d’empêcher les spammeurs d’abuser de nos systèmes. Pour profiter de limites plus élevées et d'un accès ininterrompu, abonnez-vous aux forfaits payants de <1>OpenSign™.</1>",
|
"public-credit-alert": "Signer via ce lien consomme vos crédits e-mail gratuits. En tant qu'utilisateur gratuit, vous disposez de 15 crédits e-mail par mois afin d’empêcher les spammeurs d’abuser de nos systèmes. Pour profiter de limites plus élevées et d'un accès ininterrompu, abonnez-vous aux forfaits payants de <1>OpenSign™.</1>",
|
||||||
"know-more-about": "En savoir plus sur",
|
"know-more-about": "En savoir plus sur",
|
||||||
"free-unlimited-signatures": "Signatures illimitées gratuites"
|
"free-unlimited-signatures": "Signatures illimitées gratuites",
|
||||||
|
"email-quota-updated": "Quota quotidien d'e-mails mis à jour avec succès.",
|
||||||
|
"password-has-been-reset": "Le mot de passe a été réinitialisé.",
|
||||||
|
"Unauthorized to reset your own password.": "Non autorisé à réinitialiser votre propre mot de passe.",
|
||||||
|
"User not found or not allowed.": "Utilisateur introuvable ou non autorisé.",
|
||||||
|
"User not found.": "Utilisateur introuvable.",
|
||||||
|
"Admin user tenant not found.": "Locataire administrateur introuvable.",
|
||||||
|
"User is not authenticated.": "L'utilisateur n'est pas authentifié.",
|
||||||
|
"Please provide required parameters.": "Veuillez fournir les paramètres requis.",
|
||||||
|
"reset-password": "Réinitialiser le mot de passe utilisateur",
|
||||||
|
"enter-strong-password": "Entrez un mot de passe sécurisé ou générez-en un automatiquement.",
|
||||||
|
"autogenerate": "Générer automatiquement"
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,8 @@
|
|||||||
"daily-mail-quota": "दैनिक ईमेल कोटा",
|
"daily-mail-quota": "दैनिक ईमेल कोटा",
|
||||||
"Save as template": "टेम्पलेट के रूप में सहेजें",
|
"Save as template": "टेम्पलेट के रूप में सहेजें",
|
||||||
"Fix & resend": "ठीक करें और पुनः भेजें",
|
"Fix & resend": "ठीक करें और पुनः भेजें",
|
||||||
"Kiosk Mode": "कियोस्क मोड"
|
"Kiosk Mode": "कियोस्क मोड",
|
||||||
|
"Reset password": "पासवर्ड रीसेट करें"
|
||||||
},
|
},
|
||||||
"report-heading": {
|
"report-heading": {
|
||||||
"Sr.No": "क्रमांक",
|
"Sr.No": "क्रमांक",
|
||||||
@@ -1230,5 +1231,16 @@
|
|||||||
"save-as-template-msg": "इस दस्तावेज़ को एक पुन: प्रयोज्य टेम्पलेट के रूप में सहेजें जिसे आप भविष्य के दस्तावेज़ों के लिए फिर से उपयोग कर सकते हैं।",
|
"save-as-template-msg": "इस दस्तावेज़ को एक पुन: प्रयोज्य टेम्पलेट के रूप में सहेजें जिसे आप भविष्य के दस्तावेज़ों के लिए फिर से उपयोग कर सकते हैं।",
|
||||||
"public-credit-alert": "इस लिंक के माध्यम से हस्ताक्षर करने पर आपके निःशुल्क ईमेल क्रेडिट का उपभोग होगा। एक निःशुल्क उपयोगकर्ता के रूप में, आपको स्पैमर्स को हमारी प्रणाली का दुरुपयोग करने से रोकने के लिए प्रति माह 15 ईमेल क्रेडिट आवंटित किए जाते हैं। उच्च सीमा और निर्बाध पहुँच का आनंद लेने के लिए, <1>OpenSign™ पेड प्लान</1> की सदस्यता लें।",
|
"public-credit-alert": "इस लिंक के माध्यम से हस्ताक्षर करने पर आपके निःशुल्क ईमेल क्रेडिट का उपभोग होगा। एक निःशुल्क उपयोगकर्ता के रूप में, आपको स्पैमर्स को हमारी प्रणाली का दुरुपयोग करने से रोकने के लिए प्रति माह 15 ईमेल क्रेडिट आवंटित किए जाते हैं। उच्च सीमा और निर्बाध पहुँच का आनंद लेने के लिए, <1>OpenSign™ पेड प्लान</1> की सदस्यता लें।",
|
||||||
"know-more-about": "इसके बारे में और जानें",
|
"know-more-about": "इसके बारे में और जानें",
|
||||||
"free-unlimited-signatures": "मुफ़्त असीमित हस्ताक्षर"
|
"free-unlimited-signatures": "मुफ़्त असीमित हस्ताक्षर",
|
||||||
|
"email-quota-updated": "दैनिक ईमेल कोटा सफलतापूर्वक अपडेट किया गया।",
|
||||||
|
"password-has-been-reset": "पासवर्ड रीसेट कर दिया गया है।",
|
||||||
|
"Unauthorized to reset your own password.": "अपना पासवर्ड रीसेट करने के लिए अधिकृत नहीं है।",
|
||||||
|
"User not found or not allowed.": "उपयोगकर्ता नहीं मिला या अनुमति नहीं है।",
|
||||||
|
"User not found.": "उपयोगकर्ता नहीं मिला।",
|
||||||
|
"Admin user tenant not found.": "एडमिन उपयोगकर्ता टेनेंट नहीं मिला।",
|
||||||
|
"User is not authenticated.": "उपयोगकर्ता प्रमाणीकृत नहीं है।",
|
||||||
|
"Please provide required parameters.": "कृपया आवश्यक पैरामीटर प्रदान करें।",
|
||||||
|
"reset-password": "उपयोगकर्ता पासवर्ड रीसेट करें",
|
||||||
|
"enter-strong-password": "एक मज़बूत पासवर्ड दर्ज करें या स्वचालित रूप से उत्पन्न करें।",
|
||||||
|
"autogenerate": "स्वतः उत्पन्न करें"
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,8 @@
|
|||||||
"daily-mail-quota": "Quota e-mail giornaliera",
|
"daily-mail-quota": "Quota e-mail giornaliera",
|
||||||
"Save as template": "Salva come modello",
|
"Save as template": "Salva come modello",
|
||||||
"Fix & resend": "Correggi e reinvia",
|
"Fix & resend": "Correggi e reinvia",
|
||||||
"Kiosk Mode": "Modalità Kiosk"
|
"Kiosk Mode": "Modalità Kiosk",
|
||||||
|
"Reset password": "Reimposta password"
|
||||||
},
|
},
|
||||||
"report-heading": {
|
"report-heading": {
|
||||||
"Sr.No": "Nr.",
|
"Sr.No": "Nr.",
|
||||||
@@ -1230,5 +1231,16 @@
|
|||||||
"save-as-template-msg": "Salva questo documento come modello riutilizzabile che potrai usare di nuovo per documenti futuri.",
|
"save-as-template-msg": "Salva questo documento come modello riutilizzabile che potrai usare di nuovo per documenti futuri.",
|
||||||
"public-credit-alert": "Firmare tramite questo link consumerà i tuoi crediti e-mail gratuiti. Come utente gratuito, ti vengono assegnati 15 crediti e-mail al mese per impedire agli spammer di abusare dei nostri sistemi. Per usufruire di limiti più elevati e accesso ininterrotto, abbonati ai piani a pagamento di <1>OpenSign™.</1>",
|
"public-credit-alert": "Firmare tramite questo link consumerà i tuoi crediti e-mail gratuiti. Come utente gratuito, ti vengono assegnati 15 crediti e-mail al mese per impedire agli spammer di abusare dei nostri sistemi. Per usufruire di limiti più elevati e accesso ininterrotto, abbonati ai piani a pagamento di <1>OpenSign™.</1>",
|
||||||
"know-more-about": "Scopri di più su",
|
"know-more-about": "Scopri di più su",
|
||||||
"free-unlimited-signatures": "Firme illimitate gratuite"
|
"free-unlimited-signatures": "Firme illimitate gratuite",
|
||||||
|
"email-quota-updated": "Quota e-mail giornaliera aggiornata con successo.",
|
||||||
|
"password-has-been-reset": "La password è stata reimpostata.",
|
||||||
|
"Unauthorized to reset your own password.": "Non sei autorizzato a reimpostare la tua password.",
|
||||||
|
"User not found or not allowed.": "Utente non trovato o non autorizzato.",
|
||||||
|
"User not found.": "Utente non trovato.",
|
||||||
|
"Admin user tenant not found.": "Tenant utente amministratore non trovato.",
|
||||||
|
"User is not authenticated.": "Utente non autenticato.",
|
||||||
|
"Please provide required parameters.": "Fornisci i parametri richiesti.",
|
||||||
|
"reset-password": "Reimposta password utente",
|
||||||
|
"enter-strong-password": "Inserisci una password sicura o generane una automaticamente.",
|
||||||
|
"autogenerate": "Genera automaticamente"
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,6 @@ import Loader from "./primitives/Loader";
|
|||||||
import UserList from "./pages/UserList";
|
import UserList from "./pages/UserList";
|
||||||
import { serverUrl_fn } from "./constant/appinfo";
|
import { serverUrl_fn } from "./constant/appinfo";
|
||||||
import DocSuccessPage from "./pages/DocSuccessPage";
|
import DocSuccessPage from "./pages/DocSuccessPage";
|
||||||
import ValidateSession from "./primitives/ValidateSession";
|
|
||||||
import DragProvider from "./components/DragProivder";
|
import DragProvider from "./components/DragProivder";
|
||||||
import Title from "./components/Title";
|
import Title from "./components/Title";
|
||||||
const DebugPdf = lazyWithRetry(() => import("./pages/DebugPdf"));
|
const DebugPdf = lazyWithRetry(() => import("./pages/DebugPdf"));
|
||||||
@@ -88,13 +87,7 @@ function App() {
|
|||||||
path="/forgetpassword"
|
path="/forgetpassword"
|
||||||
element={<Lazy Page={ForgetPassword} />}
|
element={<Lazy Page={ForgetPassword} />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route element={<HomeLayout />}>
|
||||||
element={
|
|
||||||
<ValidateSession>
|
|
||||||
<HomeLayout />
|
|
||||||
</ValidateSession>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Route path="/users" element={<UserList />} />
|
<Route path="/users" element={<UserList />} />
|
||||||
<Route
|
<Route
|
||||||
path="/changepassword"
|
path="/changepassword"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { appInfo } from "../constant/appinfo";
|
import { appInfo } from "../constant/appinfo";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { toggleSidebar } from "../redux/reducers/sidebarReducer.js";
|
import { toggleSidebar } from "../redux/reducers/sidebarReducer.js";
|
||||||
|
import { sessionStatus } from "../redux/reducers/userReducer.js";
|
||||||
|
|
||||||
const Header = ({ isConsole, setIsLoggingOut }) => {
|
const Header = ({ isConsole, setIsLoggingOut }) => {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
@@ -67,6 +68,8 @@ const Header = ({ isConsole, setIsLoggingOut }) => {
|
|||||||
await Parse.User.logOut();
|
await Parse.User.logOut();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("Err while logging out", err);
|
console.log("Err while logging out", err);
|
||||||
|
} finally {
|
||||||
|
dispatch(sessionStatus(true));
|
||||||
}
|
}
|
||||||
let appdata = localStorage.getItem("userSettings");
|
let appdata = localStorage.getItem("userSettings");
|
||||||
let applogo = localStorage.getItem("appLogo");
|
let applogo = localStorage.getItem("appLogo");
|
||||||
|
|||||||
@@ -4,21 +4,22 @@ import Footer from "../components/Footer";
|
|||||||
import Sidebar from "../components/sidebar/Sidebar";
|
import Sidebar from "../components/sidebar/Sidebar";
|
||||||
import Tour from "../primitives/Tour";
|
import Tour from "../primitives/Tour";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import Parse from "parse";
|
import Parse from "parse";
|
||||||
import ModalUi from "../primitives/ModalUi";
|
import { useNavigate, Outlet } from "react-router";
|
||||||
import { useNavigate, useLocation, Outlet } from "react-router";
|
|
||||||
import Loader from "../primitives/Loader";
|
import Loader from "../primitives/Loader";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { sessionStatus } from "../redux/reducers/userReducer";
|
||||||
|
import SessionExpiredModal from "../primitives/SessionExpiredModal";
|
||||||
|
|
||||||
const HomeLayout = () => {
|
const HomeLayout = () => {
|
||||||
const appName =
|
const appName =
|
||||||
"OpenSign™";
|
"OpenSign™";
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const dispatch = useDispatch();
|
||||||
const arr = useSelector((state) => state.TourSteps);
|
const arr = useSelector((state) => state.TourSteps);
|
||||||
const [isUserValid, setIsUserValid] = useState(true);
|
const isValidSession = useSelector((state) => state.user.isValidSession);
|
||||||
const [isLoader, setIsLoader] = useState(true);
|
const [isLoader, setIsLoader] = useState(true);
|
||||||
const [isCloseBtn, setIsCloseBtn] = useState(true);
|
const [isCloseBtn, setIsCloseBtn] = useState(true);
|
||||||
const [isTour, setIsTour] = useState(false);
|
const [isTour, setIsTour] = useState(false);
|
||||||
@@ -35,28 +36,31 @@ const HomeLayout = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!tenantId) {
|
if (localStorage.getItem("accesstoken")) {
|
||||||
setIsUserValid(false);
|
if (!tenantId) {
|
||||||
} else {
|
dispatch(sessionStatus(false));
|
||||||
(async () => {
|
} else {
|
||||||
try {
|
(async () => {
|
||||||
// Use the session token to validate the user
|
try {
|
||||||
const userQuery = new Parse.Query(Parse.User);
|
// Use the session token to validate the user
|
||||||
const user = await userQuery.get(Parse?.User?.current()?.id, {
|
const userQuery = new Parse.Query(Parse.User);
|
||||||
sessionToken: localStorage.getItem("accesstoken")
|
const user = await userQuery.get(Parse?.User?.current()?.id, {
|
||||||
});
|
sessionToken: localStorage.getItem("accesstoken")
|
||||||
if (user) {
|
});
|
||||||
localStorage.setItem("profileImg", user.get("ProfilePic") || "");
|
if (user) {
|
||||||
setIsUserValid(true);
|
localStorage.setItem("profileImg", user.get("ProfilePic") || "");
|
||||||
setIsLoader(false);
|
dispatch(sessionStatus(true));
|
||||||
} else {
|
setIsLoader(false);
|
||||||
setIsUserValid(false);
|
} else {
|
||||||
|
dispatch(sessionStatus(true));
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("catch");
|
||||||
|
// Session token is invalid or there was an error
|
||||||
|
dispatch(sessionStatus(false));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
})();
|
||||||
// Session token is invalid or there was an error
|
}
|
||||||
setIsUserValid(false);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@@ -169,77 +173,56 @@ const HomeLayout = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleLoginBtn = async () => {
|
return isValidSession && localStorage.getItem("accesstoken") ? (
|
||||||
try {
|
|
||||||
await Parse?.User?.logOut();
|
|
||||||
} catch (err) {
|
|
||||||
console.log("err ", err);
|
|
||||||
} finally {
|
|
||||||
localStorage.removeItem("accesstoken");
|
|
||||||
navigate("/", { replace: true, state: { from: location } });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col h-screen overflow-hidden">
|
<div className="flex flex-col h-screen overflow-hidden">
|
||||||
{/* HEADER */}
|
{/* HEADER */}
|
||||||
<header className="z-[501]">
|
<header className="z-[501]">
|
||||||
{!isLoader && <Header setIsLoggingOut={setIsLoggingOut} />}
|
{!isLoader && <Header setIsLoggingOut={setIsLoggingOut} />}
|
||||||
</header>
|
</header>
|
||||||
{isUserValid ? (
|
{isLoader ? (
|
||||||
|
<div className="flex h-[100vh] justify-center items-center">
|
||||||
|
<Loader />
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
<>
|
<>
|
||||||
{isLoader ? (
|
{isLoggingOut && (
|
||||||
<div className="flex h-[100vh] justify-center items-center">
|
<div className="inset-0 bg-black/30 z-[1000] fixed flex justify-center items-center">
|
||||||
<Loader />
|
<Loader />
|
||||||
</div>
|
</div>
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{isLoggingOut && (
|
|
||||||
<div className="inset-0 bg-black/30 z-[1000] fixed flex justify-center items-center">
|
|
||||||
<Loader />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{/* BODY */}
|
|
||||||
<div className="flex flex-1 overflow-hidden">
|
|
||||||
{/* SIDEBAR with width animation */}
|
|
||||||
<Sidebar />
|
|
||||||
{/* MAIN (includes both content + footer in one scrollable column) */}
|
|
||||||
<main
|
|
||||||
id="renderList"
|
|
||||||
className="flex-1 overflow-auto transition-all duration-300 ease-in-out"
|
|
||||||
>
|
|
||||||
<div className="flex flex-col min-h-full">
|
|
||||||
{/* your page content */}
|
|
||||||
<div className="p-3">{<Outlet />}</div>
|
|
||||||
{/* sticky-but-scrollable footer */}
|
|
||||||
<div className="mt-auto z-30">
|
|
||||||
<Footer />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
<Tour
|
|
||||||
onRequestClose={closeTour}
|
|
||||||
steps={tourConfigs}
|
|
||||||
isOpen={isTour}
|
|
||||||
disableKeyboardNavigation={["esc"]}
|
|
||||||
// disableInteraction={true}
|
|
||||||
scrollOffset={-100}
|
|
||||||
showCloseButton={isCloseBtn}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</>
|
{/* BODY */}
|
||||||
) : (
|
<div className="flex flex-1 overflow-hidden">
|
||||||
<ModalUi showHeader={false} isOpen={true} showClose={false}>
|
{/* SIDEBAR with width animation */}
|
||||||
<div className="flex flex-col justify-center items-center py-4 md:py-5 gap-5">
|
<Sidebar />
|
||||||
<p className="text-xl font-medium">{t("session-expired")}</p>
|
{/* MAIN (includes both content + footer in one scrollable column) */}
|
||||||
<button onClick={handleLoginBtn} className="op-btn op-btn-neutral">
|
<main
|
||||||
{t("login")}
|
id="renderList"
|
||||||
</button>
|
className="flex-1 overflow-auto transition-all duration-300 ease-in-out"
|
||||||
|
>
|
||||||
|
<div className="flex flex-col min-h-full">
|
||||||
|
{/* your page content */}
|
||||||
|
<div className="p-3">{<Outlet />}</div>
|
||||||
|
{/* sticky-but-scrollable footer */}
|
||||||
|
<div className="mt-auto z-30">
|
||||||
|
<Footer />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</ModalUi>
|
<Tour
|
||||||
|
onRequestClose={closeTour}
|
||||||
|
steps={tourConfigs}
|
||||||
|
isOpen={isTour}
|
||||||
|
disableKeyboardNavigation={["esc"]}
|
||||||
|
// disableInteraction={true}
|
||||||
|
scrollOffset={-100}
|
||||||
|
showCloseButton={isCloseBtn}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
<SessionExpiredModal />
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ import ModalUi from "../primitives/ModalUi";
|
|||||||
import { Tooltip } from "react-tooltip";
|
import { Tooltip } from "react-tooltip";
|
||||||
import Loader from "../primitives/Loader";
|
import Loader from "../primitives/Loader";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useDispatch } from "react-redux";
|
||||||
|
import { sessionStatus } from "../redux/reducers/userReducer";
|
||||||
|
|
||||||
// `Form` render all type of Form on this basis of their provided in path
|
// `Form` render all type of Form on this basis of their provided in path
|
||||||
function Form() {
|
function Form() {
|
||||||
@@ -50,6 +52,7 @@ const Forms = (props) => {
|
|||||||
const abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
const inputFileRef = useRef(null);
|
const inputFileRef = useRef(null);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const dispatch = useDispatch();
|
||||||
const [signers, setSigners] = useState([]);
|
const [signers, setSigners] = useState([]);
|
||||||
const [folder, setFolder] = useState({ ObjectId: "", Name: "" });
|
const [folder, setFolder] = useState({ ObjectId: "", Name: "" });
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
@@ -277,7 +280,11 @@ const Forms = (props) => {
|
|||||||
console.log("err in docx to pdf ", err);
|
console.log("err in docx to pdf ", err);
|
||||||
const error =
|
const error =
|
||||||
t("docx-error");
|
t("docx-error");
|
||||||
alert(error);
|
if (err?.code === 209) {
|
||||||
|
dispatch(sessionStatus(false));
|
||||||
|
} else {
|
||||||
|
alert(error);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -335,7 +342,11 @@ const Forms = (props) => {
|
|||||||
setSelectedFiles([]);
|
setSelectedFiles([]);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(error.message);
|
if (error?.code === 209) {
|
||||||
|
dispatch(sessionStatus(false));
|
||||||
|
} else {
|
||||||
|
alert(error.message);
|
||||||
|
}
|
||||||
setSelectedFiles([]);
|
setSelectedFiles([]);
|
||||||
removeFile(e);
|
removeFile(e);
|
||||||
}
|
}
|
||||||
@@ -472,7 +483,9 @@ const Forms = (props) => {
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("err ", err);
|
console.log("err ", err);
|
||||||
if (err.message === "only 15 reminder allowed") {
|
if (err?.code === 209) {
|
||||||
|
dispatch(sessionStatus(false));
|
||||||
|
} else if (err.message === "only 15 reminder allowed") {
|
||||||
setIsAlert({
|
setIsAlert({
|
||||||
type: "danger",
|
type: "danger",
|
||||||
message: t("only-15-reminder-allowed")
|
message: t("only-15-reminder-allowed")
|
||||||
@@ -604,7 +617,9 @@ const Forms = (props) => {
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
removeFile();
|
removeFile();
|
||||||
if (err?.response?.status === 401) {
|
if (err?.code === 209) {
|
||||||
|
dispatch(sessionStatus(false));
|
||||||
|
} else if (err?.response?.status === 401) {
|
||||||
setIsPassword(true);
|
setIsPassword(true);
|
||||||
setIsCorrectPass(false);
|
setIsCorrectPass(false);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
} from "react-i18next";
|
} from "react-i18next";
|
||||||
import DeleteUserModal from "../primitives/DeleteUserModal";
|
import DeleteUserModal from "../primitives/DeleteUserModal";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import PasswordResetModal from "../primitives/PasswordResetModal";
|
||||||
|
|
||||||
const actions = [
|
const actions = [
|
||||||
{
|
{
|
||||||
@@ -23,6 +24,14 @@ const actions = [
|
|||||||
action: "delete",
|
action: "delete",
|
||||||
restrictAdmin: true
|
restrictAdmin: true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
btnId: "1910",
|
||||||
|
hoverLabel: "Reset password",
|
||||||
|
btnIcon: "fa-light fa-key",
|
||||||
|
redirectUrl: "",
|
||||||
|
action: "resetpassword",
|
||||||
|
restrictAdmin: true
|
||||||
|
},
|
||||||
];
|
];
|
||||||
const heading = ["Sr.No", "Name", "Email", "Phone", "Role", "Team", "Active"];
|
const heading = ["Sr.No", "Name", "Email", "Phone", "Role", "Team", "Active"];
|
||||||
const UserList = () => {
|
const UserList = () => {
|
||||||
@@ -208,9 +217,9 @@ const UserList = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// `showAlert` handle show/hide alert
|
// `showAlert` handle show/hide alert
|
||||||
const showAlert = (type, msg) => {
|
const showAlert = (type, msg, timer = 1500) => {
|
||||||
setIsAlert({ type, msg });
|
setIsAlert({ type, msg });
|
||||||
setTimeout(() => setIsAlert({ type: "success", msg: "" }), 1500);
|
setTimeout(() => setIsAlert({ type: "success", msg: "" }), timer);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteAccount = async (item) => {
|
const handleDeleteAccount = async (item) => {
|
||||||
@@ -247,13 +256,15 @@ const UserList = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleActionBtn = async (act, item) => {
|
const handleActionBtn = async (act, item) => {
|
||||||
if (act.action === "delete") {
|
setIsActModal({ [`${act.action}_${item.objectId}`]: true });
|
||||||
setIsActModal({ [`delete_${item.objectId}`]: true });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
const handleBtnVisibility = (act, item) => {
|
const handleBtnVisibility = (act, item) => {
|
||||||
if (act.restrictAdmin) {
|
if (act.restrictAdmin) {
|
||||||
return item?.objectId !== extClass?.[0]?.objectId;
|
if (item?.UserRole === "contracts_Admin") {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return item?.objectId !== extClass?.[0]?.objectId;
|
||||||
|
}
|
||||||
} else if (
|
} else if (
|
||||||
act.restrictBtn === true &&
|
act.restrictBtn === true &&
|
||||||
item?.objectId === extClass?.[0]?.objectId
|
item?.objectId === extClass?.[0]?.objectId
|
||||||
@@ -263,6 +274,28 @@ const UserList = () => {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const handleActiveToggleVisibility = (item) => {
|
||||||
|
if (item?.UserRole === "contracts_Admin") {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return item?.objectId !== extClass?.[0]?.objectId;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
async function submitPassword(userId, password) {
|
||||||
|
setIsLoader(true);
|
||||||
|
setIsActModal({});
|
||||||
|
try {
|
||||||
|
const params = { userId, password };
|
||||||
|
await Parse.Cloud.run("resetpassword", params);
|
||||||
|
showAlert("success", t("password-has-been-reset"));
|
||||||
|
} catch (err) {
|
||||||
|
console.log("err while reset password", err);
|
||||||
|
showAlert("danger", t(err.message), 2000);
|
||||||
|
} finally {
|
||||||
|
setIsLoader(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
{isLoader && (
|
{isLoader && (
|
||||||
@@ -340,7 +373,7 @@ const UserList = () => {
|
|||||||
<td className="px-4 py-2">
|
<td className="px-4 py-2">
|
||||||
{formatRow(item.TeamIds)}
|
{formatRow(item.TeamIds)}
|
||||||
</td>
|
</td>
|
||||||
{item.UserRole !== "contracts_Admin" ? (
|
{handleActiveToggleVisibility(item) ? (
|
||||||
<td className="px-4 py-2 font-semibold">
|
<td className="px-4 py-2 font-semibold">
|
||||||
<label className="cursor-pointer relative block items-center mb-0">
|
<label className="cursor-pointer relative block items-center mb-0">
|
||||||
<input
|
<input
|
||||||
@@ -436,6 +469,17 @@ const UserList = () => {
|
|||||||
deleteRes={deleteUserRes}
|
deleteRes={deleteUserRes}
|
||||||
handleClose={handleCloseModal}
|
handleClose={handleCloseModal}
|
||||||
/>
|
/>
|
||||||
|
<PasswordResetModal
|
||||||
|
isOpen={
|
||||||
|
isActModal[
|
||||||
|
"resetpassword_" + item.objectId
|
||||||
|
]
|
||||||
|
}
|
||||||
|
userId={item?.UserId?.objectId}
|
||||||
|
onClose={handleCloseModal}
|
||||||
|
onSubmit={submitPassword}
|
||||||
|
showAlert={showAlert}
|
||||||
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,205 @@
|
|||||||
|
import { useMemo, useState } from "react";
|
||||||
|
import ModalUi from "./ModalUi";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PasswordResetModal
|
||||||
|
* - Validates password rules (length >= 8, upper, lower, digit, special)
|
||||||
|
* - Buttons: Submit, Autogenerate (12 chars), Copy (Font Awesome icon only)
|
||||||
|
* - `Autogenerate` fills a valid 12-char password but remains editable
|
||||||
|
* - `Copy` copies the current password to clipboard
|
||||||
|
*
|
||||||
|
* Props:
|
||||||
|
* - isOpen: boolean
|
||||||
|
* - onClose: () => void
|
||||||
|
* - onSubmit: (password: string) => Promise<void> | void
|
||||||
|
*/
|
||||||
|
export default function PasswordResetModal({
|
||||||
|
userId,
|
||||||
|
isOpen,
|
||||||
|
onClose,
|
||||||
|
onSubmit,
|
||||||
|
showAlert
|
||||||
|
}) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [password, setPassword] = useState("");
|
||||||
|
const [submitting, setSubmitting] = useState(false);
|
||||||
|
const [copied, setCopied] = useState(false);
|
||||||
|
|
||||||
|
// Validation helpers
|
||||||
|
const rules = useMemo(
|
||||||
|
() => ({
|
||||||
|
hasUpper: /[A-Z]/,
|
||||||
|
hasLower: /[a-z]/,
|
||||||
|
hasDigit: /\d/,
|
||||||
|
// Richer special set including common keyboard symbols
|
||||||
|
hasSpecial: /[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?`~]/,
|
||||||
|
minLen: 8
|
||||||
|
}),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
|
||||||
|
const checks = useMemo(() => {
|
||||||
|
return {
|
||||||
|
lenOK: password.length >= rules.minLen,
|
||||||
|
upperLowerDigitOK:
|
||||||
|
rules.hasUpper.test(password) &&
|
||||||
|
rules.hasLower.test(password) &&
|
||||||
|
rules.hasDigit.test(password),
|
||||||
|
specialOK: rules.hasSpecial.test(password)
|
||||||
|
};
|
||||||
|
}, [password, rules]);
|
||||||
|
|
||||||
|
// Always-present condition list with per-condition status
|
||||||
|
const conditions = useMemo(
|
||||||
|
() => [
|
||||||
|
{
|
||||||
|
key: "len",
|
||||||
|
ok: checks.lenOK,
|
||||||
|
text: "password-length"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "uld",
|
||||||
|
ok: checks.upperLowerDigitOK,
|
||||||
|
text: "password-case"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "spec",
|
||||||
|
ok: checks.specialOK,
|
||||||
|
text: "password-special-case"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[checks]
|
||||||
|
);
|
||||||
|
|
||||||
|
const allValid = conditions.every((c) => c.ok) && password.length > 0;
|
||||||
|
|
||||||
|
// Autogenerate a valid random password (12 chars)
|
||||||
|
const handleAutogen = () => {
|
||||||
|
const length = 12;
|
||||||
|
const upper = "ABCDEFGHJKLMNPQRSTUVWXYZ"; // omit ambiguous I/O
|
||||||
|
const lower = "abcdefghijkmnopqrstuvwxyz"; // omit ambiguous l
|
||||||
|
const digits = "23456789"; // omit 0/1
|
||||||
|
const special = "!@#$%^&*()-_=+[]{};:,.?";
|
||||||
|
const all = upper + lower + digits + special;
|
||||||
|
|
||||||
|
function pick(str) {
|
||||||
|
return str[Math.floor(Math.random() * str.length)];
|
||||||
|
}
|
||||||
|
function shuffle(arr) {
|
||||||
|
return arr.sort(() => Math.random() - 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
let pwd = [pick(upper), pick(lower), pick(digits), pick(special)];
|
||||||
|
while (pwd.length < length) pwd.push(pick(all));
|
||||||
|
pwd = shuffle(pwd).join("");
|
||||||
|
|
||||||
|
setPassword(pwd);
|
||||||
|
};
|
||||||
|
const handleCopy = async () => {
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(password);
|
||||||
|
showAlert("success", t("copied"), 1200);
|
||||||
|
setCopied(true);
|
||||||
|
setTimeout(() => setCopied(false, 1200));
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Clipboard error", e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async (e) => {
|
||||||
|
e?.preventDefault?.();
|
||||||
|
if (!allValid) return; // guard
|
||||||
|
try {
|
||||||
|
setSubmitting(true);
|
||||||
|
await onSubmit?.(userId, password);
|
||||||
|
setSubmitting(false);
|
||||||
|
onClose?.();
|
||||||
|
setPassword("");
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
setSubmitting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ModalUi
|
||||||
|
isOpen={isOpen}
|
||||||
|
title={t("reset-password")}
|
||||||
|
handleClose={() => {
|
||||||
|
setPassword("");
|
||||||
|
onClose?.();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<form onSubmit={handleSubmit} className="space-y-3 pt-[15px] p-[20px]">
|
||||||
|
<p className="text-sm text-base-content/60">
|
||||||
|
{t("enter-strong-password")}
|
||||||
|
</p>
|
||||||
|
<label className="op-form-control w-full">
|
||||||
|
<div className="op-label">
|
||||||
|
<span className="op-label-text">{t("new-password")}</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="op-input op-input-bordered op-input-sm focus:outline-none hover:border-base-content w-full text-xs"
|
||||||
|
placeholder="Enter password or click Autogenerate"
|
||||||
|
value={password}
|
||||||
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
|
autoFocus
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="op-btn op-btn-square op-btn-sm"
|
||||||
|
onClick={handleCopy}
|
||||||
|
title={copied ? "Copied" : "Copy"}
|
||||||
|
aria-label="Copy password"
|
||||||
|
disabled={!password}
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
className={`fa-regular fa-copy ${copied ? "opacity-70" : ""}`}
|
||||||
|
></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
{/* When everything is valid, show just a right tick */}
|
||||||
|
<ul className="mt-1 ml-2">
|
||||||
|
{conditions.map((c) => (
|
||||||
|
<li
|
||||||
|
key={c.key}
|
||||||
|
className={`${c.ok ? "text-success" : "text-error"} text-[12px] leading-snug`}
|
||||||
|
>
|
||||||
|
{c.ok ? "✓" : "✗"} {t(c.text)}
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div className="pt-2 flex flex-row gap-x-2">
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="op-btn op-btn-primary"
|
||||||
|
disabled={!allValid || submitting}
|
||||||
|
>
|
||||||
|
{t("submit")}
|
||||||
|
</button>
|
||||||
|
<button type="button" className="op-btn" onClick={handleAutogen}>
|
||||||
|
{t("autogenerate")}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="op-btn op-btn-ghost"
|
||||||
|
onClick={() => {
|
||||||
|
setPassword("");
|
||||||
|
onClose?.();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("cancel")}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</ModalUi>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
+13
-10
@@ -1,26 +1,29 @@
|
|||||||
import React from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import ModalUi from "./ModalUi";
|
import { useLocation, useNavigate } from "react-router";
|
||||||
import { useNavigate } from "react-router";
|
import { useDispatch } from "react-redux";
|
||||||
|
import { sessionStatus } from "../redux/reducers/userReducer";
|
||||||
import Parse from "parse";
|
import Parse from "parse";
|
||||||
|
import ModalUi from "./ModalUi";
|
||||||
|
|
||||||
const ValidateSession = ({ children }) => {
|
const SessionExpiredModal = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const location = useLocation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const handleLoginBtn = async () => {
|
const handleLoginBtn = async () => {
|
||||||
try {
|
try {
|
||||||
await Parse?.User?.logOut();
|
await Parse?.User?.logOut();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log("err ", err);
|
console.log(`err: ${err}`);
|
||||||
} finally {
|
} finally {
|
||||||
localStorage.removeItem("accesstoken");
|
localStorage.removeItem("accesstoken");
|
||||||
navigate("/", { replace: true });
|
dispatch(sessionStatus(true));
|
||||||
|
navigate("/", { replace: true, state: { from: location } });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return localStorage.getItem("accesstoken") ? (
|
|
||||||
children
|
return (
|
||||||
) : (
|
|
||||||
<ModalUi showHeader={false} isOpen={true} showClose={false}>
|
<ModalUi showHeader={false} isOpen={true} showClose={false}>
|
||||||
<div className="flex flex-col justify-center items-center py-4 md:py-5 gap-5">
|
<div className="flex flex-col justify-center items-center py-4 md:py-5 gap-5">
|
||||||
<p className="text-xl font-medium">{t("session-expired")}</p>
|
<p className="text-xl font-medium">{t("session-expired")}</p>
|
||||||
@@ -32,4 +35,4 @@ const ValidateSession = ({ children }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ValidateSession;
|
export default SessionExpiredModal;
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import Parse from "parse";
|
import Parse from "parse";
|
||||||
import { Outlet, useNavigate, useLocation } from "react-router";
|
import { Outlet } from "react-router";
|
||||||
import ModalUi from "./ModalUi";
|
import SessionExpiredModal from "./SessionExpiredModal";
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
const Validate = () => {
|
const Validate = () => {
|
||||||
const navigate = useNavigate();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
const location = useLocation();
|
|
||||||
const [isUserValid, setIsUserValid] = useState(true);
|
const [isUserValid, setIsUserValid] = useState(true);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
@@ -37,30 +34,7 @@ const Validate = () => {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleLoginBtn = async () => {
|
return isUserValid ? <Outlet /> : <SessionExpiredModal />;
|
||||||
try {
|
|
||||||
await Parse.User.logOut();
|
|
||||||
} catch (err) {
|
|
||||||
console.log("err ", err);
|
|
||||||
} finally {
|
|
||||||
localStorage.removeItem("accesstoken");
|
|
||||||
navigate("/", { replace: true, state: { from: location } });
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return isUserValid ? (
|
|
||||||
<div>
|
|
||||||
<Outlet />
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<ModalUi showHeader={false} isOpen={true} showClose={false}>
|
|
||||||
<div className="flex flex-col justify-center items-center py-4 md:py-5 gap-5">
|
|
||||||
<p className="text-xl font-medium">{t("session-expired")}</p>
|
|
||||||
<button onClick={handleLoginBtn} className="op-btn op-btn-neutral">
|
|
||||||
{t("login")}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</ModalUi>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Validate;
|
export default Validate;
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { createSlice } from "@reduxjs/toolkit";
|
||||||
|
const initialState = { isValidSession: true };
|
||||||
|
const userReducer = createSlice({
|
||||||
|
name: "user",
|
||||||
|
initialState: initialState,
|
||||||
|
reducers: {
|
||||||
|
sessionStatus: (state, action) => {
|
||||||
|
state.isValidSession = action.payload;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const { sessionStatus } = userReducer.actions;
|
||||||
|
|
||||||
|
export default userReducer.reducer;
|
||||||
@@ -4,6 +4,7 @@ import ShowTenant from "./reducers/ShowTenant";
|
|||||||
import TourStepsReducer from "./reducers/TourStepsReducer";
|
import TourStepsReducer from "./reducers/TourStepsReducer";
|
||||||
import widgetReducer from "./reducers/widgetSlice";
|
import widgetReducer from "./reducers/widgetSlice";
|
||||||
import sidebarReducer from "./reducers/sidebarReducer";
|
import sidebarReducer from "./reducers/sidebarReducer";
|
||||||
|
import userReducer from "./reducers/userReducer";
|
||||||
|
|
||||||
export const store = configureStore({
|
export const store = configureStore({
|
||||||
reducer: {
|
reducer: {
|
||||||
@@ -11,6 +12,7 @@ export const store = configureStore({
|
|||||||
TourSteps: TourStepsReducer,
|
TourSteps: TourStepsReducer,
|
||||||
ShowTenant,
|
ShowTenant,
|
||||||
widget: widgetReducer,
|
widget: widgetReducer,
|
||||||
sidebar: sidebarReducer
|
sidebar: sidebarReducer,
|
||||||
|
user: userReducer
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -106,6 +106,15 @@ const DocumentsReport = (props) => {
|
|||||||
}
|
}
|
||||||
}, [props.isSearchResult]);
|
}, [props.isSearchResult]);
|
||||||
|
|
||||||
|
// Close dropdown when clicking outside or on button again
|
||||||
|
useEffect(() => {
|
||||||
|
const onDocClick = (e) => {
|
||||||
|
if (!e.target.closest('[data-dropdown-root="1"]')) setIsOption({});
|
||||||
|
};
|
||||||
|
document.addEventListener("click", onDocClick);
|
||||||
|
return () => document.removeEventListener("click", onDocClick);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const getPaginationRange = () => {
|
const getPaginationRange = () => {
|
||||||
const totalPageNumbers = 7; // Adjust this value to show more/less page numbers
|
const totalPageNumbers = 7; // Adjust this value to show more/less page numbers
|
||||||
const pages = [];
|
const pages = [];
|
||||||
@@ -1174,6 +1183,7 @@ const DocumentsReport = (props) => {
|
|||||||
<React.Fragment key={index}>
|
<React.Fragment key={index}>
|
||||||
{handleBtnVisibility(act, item) && (
|
{handleBtnVisibility(act, item) && (
|
||||||
<div
|
<div
|
||||||
|
data-dropdown-root="1"
|
||||||
role="button"
|
role="button"
|
||||||
data-tut={act?.selector}
|
data-tut={act?.selector}
|
||||||
onClick={() => handleActionBtn(act, item)}
|
onClick={() => handleActionBtn(act, item)}
|
||||||
|
|||||||
@@ -165,6 +165,15 @@ const TemplatesReport = (props) => {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// Close dropdown when clicking outside or on button again
|
||||||
|
useEffect(() => {
|
||||||
|
const onDocClick = (e) => {
|
||||||
|
if (!e.target.closest('[data-dropdown-root="1"]')) setIsOption({});
|
||||||
|
};
|
||||||
|
document.addEventListener("click", onDocClick);
|
||||||
|
return () => document.removeEventListener("click", onDocClick);
|
||||||
|
}, []);
|
||||||
|
|
||||||
// `fetchTeamList` is used to fetch team list for share with functionality
|
// `fetchTeamList` is used to fetch team list for share with functionality
|
||||||
const fetchTeamList = async () => {
|
const fetchTeamList = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -1152,6 +1161,7 @@ const TemplatesReport = (props) => {
|
|||||||
role="button"
|
role="button"
|
||||||
data-tut={act?.selector}
|
data-tut={act?.selector}
|
||||||
key={index}
|
key={index}
|
||||||
|
data-dropdown-root="1"
|
||||||
onClick={() => handleActionBtn(act, item)}
|
onClick={() => handleActionBtn(act, item)}
|
||||||
title={t(`btnLabel.${act.hoverLabel}`)}
|
title={t(`btnLabel.${act.hoverLabel}`)}
|
||||||
className={
|
className={
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const resetPasswordAndDeleteSession = async userId => {
|
|||||||
await Parse.Object.destroyAll(sessions, { useMasterKey: true });
|
await Parse.Object.destroyAll(sessions, { useMasterKey: true });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
export async function deleteUser(userId, adminId) {
|
export async function deleteUser(userId, adminId, adminTenantId, isOrgAdmin, orgPtr) {
|
||||||
const userPointer = { __type: 'Pointer', className: '_User', objectId: userId };
|
const userPointer = { __type: 'Pointer', className: '_User', objectId: userId };
|
||||||
let userDetails = {
|
let userDetails = {
|
||||||
UserRole: 'not found',
|
UserRole: 'not found',
|
||||||
@@ -47,13 +47,18 @@ export async function deleteUser(userId, adminId) {
|
|||||||
const Users = Parse.Object.extend('contracts_Users');
|
const Users = Parse.Object.extend('contracts_Users');
|
||||||
const userQuery = new Parse.Query(Users);
|
const userQuery = new Parse.Query(Users);
|
||||||
userQuery.equalTo('UserId', userPointer);
|
userQuery.equalTo('UserId', userPointer);
|
||||||
if (adminId) {
|
if (adminTenantId) {
|
||||||
|
userQuery.equalTo('TenantId', adminTenantId);
|
||||||
|
if (isOrgAdmin && orgPtr) {
|
||||||
|
userQuery.equalTo('OrganizationId', orgPtr);
|
||||||
|
}
|
||||||
|
} else if (adminId) {
|
||||||
userQuery.equalTo('CreatedBy', { __type: 'Pointer', className: '_User', objectId: adminId });
|
userQuery.equalTo('CreatedBy', { __type: 'Pointer', className: '_User', objectId: adminId });
|
||||||
}
|
}
|
||||||
const userResult = await userQuery.first({ useMasterKey: true });
|
const userResult = await userQuery.first({ useMasterKey: true });
|
||||||
userDetails = { ...userDetails, UserId: userId };
|
userDetails = { ...userDetails, UserId: userId };
|
||||||
if (!userResult) {
|
if (!userResult) {
|
||||||
const errorMessage = 'User not found.';
|
const errorMessage = isOrgAdmin ? 'Unauthorized.' : 'User not found.';
|
||||||
return { code: 400, message: errorMessage };
|
return { code: 400, message: errorMessage };
|
||||||
}
|
}
|
||||||
const contractsUserId = userResult.id;
|
const contractsUserId = userResult.id;
|
||||||
@@ -61,6 +66,10 @@ export async function deleteUser(userId, adminId) {
|
|||||||
const teamIds = userResult.get('TeamIds') || [];
|
const teamIds = userResult.get('TeamIds') || [];
|
||||||
const organizationId = userResult.get('OrganizationId')?.id;
|
const organizationId = userResult.get('OrganizationId')?.id;
|
||||||
const isAdmin = userResult?.get('UserRole') === 'contracts_Admin' ? true : false;
|
const isAdmin = userResult?.get('UserRole') === 'contracts_Admin' ? true : false;
|
||||||
|
if (isOrgAdmin && isAdmin) {
|
||||||
|
const errorMessage = 'Unauthorized.';
|
||||||
|
return { code: 400, message: errorMessage };
|
||||||
|
}
|
||||||
userDetails = {
|
userDetails = {
|
||||||
...userDetails,
|
...userDetails,
|
||||||
UserRole: userResult?.get('UserRole'),
|
UserRole: userResult?.get('UserRole'),
|
||||||
@@ -267,6 +276,21 @@ export const deleteUserPost = async (req, res) => {
|
|||||||
return res.send(errorMessage);
|
return res.send(errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extUser?.get('UserRole') !== 'contracts_Admin') {
|
||||||
|
const errorMessage =
|
||||||
|
'This action is not permitted. Kindly contact your administrator to request account deletion.';
|
||||||
|
return res.send(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
const extUsers = new Parse.Query('contracts_Users');
|
||||||
|
extUsers.equalTo('TenantId', extUser?.get('TenantId'));
|
||||||
|
extUsers.notEqualTo('UserRole', 'contracts_Admin');
|
||||||
|
const isTeamUsers = await extUsers.first({ useMasterKey: true });
|
||||||
|
if (isTeamUsers) {
|
||||||
|
const errorMessage = `To delete this account, start by removing all team users associated with it. Once all users are removed, you'll be able to permanently delete the account.`;
|
||||||
|
return res.send(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
// Get stored OTP info
|
// Get stored OTP info
|
||||||
const savedOtp = extUser.get('DeleteOTP') || '';
|
const savedOtp = extUser.get('DeleteOTP') || '';
|
||||||
const expiry = extUser.get('DeleteOTPExpiry');
|
const expiry = extUser.get('DeleteOTPExpiry');
|
||||||
@@ -352,7 +376,30 @@ export const deleteUserByAdmin = async (req, res) => {
|
|||||||
const errorMessage = 'User not found.';
|
const errorMessage = 'User not found.';
|
||||||
return res.status(400).json({ message: errorMessage });
|
return res.status(400).json({ message: errorMessage });
|
||||||
}
|
}
|
||||||
const response = await deleteUser(userId, adminId);
|
|
||||||
|
if (adminId === userId) {
|
||||||
|
return res.status(400).json({ message: 'You cannot delete your own account.' });
|
||||||
|
}
|
||||||
|
// 2. ext user details
|
||||||
|
const extUserQuery = new Parse.Query('contracts_Users');
|
||||||
|
extUserQuery.equalTo('UserId', { __type: 'Pointer', className: '_User', objectId: adminId });
|
||||||
|
const extUser = await extUserQuery.first({ useMasterKey: true });
|
||||||
|
if (!extUser) {
|
||||||
|
const errorMessage = 'User not found.';
|
||||||
|
return res.status(400).json({ message: errorMessage });
|
||||||
|
}
|
||||||
|
const isAdmin =
|
||||||
|
extUser?.get('UserRole') === 'contracts_Admin' ||
|
||||||
|
extUser?.get('UserRole') === 'contracts_OrgAdmin'
|
||||||
|
? true
|
||||||
|
: false;
|
||||||
|
const isOrgAdmin = extUser?.get('UserRole') === 'contracts_OrgAdmin';
|
||||||
|
const tenantId = extUser?.get('TenantId');
|
||||||
|
const orgPtr = isOrgAdmin && extUser?.get('OrganizationId');
|
||||||
|
if (!isAdmin) {
|
||||||
|
return res.status(400).json({ message: 'Unauthorized.' });
|
||||||
|
}
|
||||||
|
const response = await deleteUser(userId, adminId, tenantId, isOrgAdmin, orgPtr);
|
||||||
const code = response?.code || 400;
|
const code = response?.code || 400;
|
||||||
const message = response?.message || 'An error occurred while deleting your account.';
|
const message = response?.message || 'An error occurred while deleting your account.';
|
||||||
return res.status(code).json({ message: message });
|
return res.status(code).json({ message: message });
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ import loginUser from './parsefunction/loginUser.js';
|
|||||||
import addUser from './parsefunction/addUser.js';
|
import addUser from './parsefunction/addUser.js';
|
||||||
import filterDocs from './parsefunction/filterDocs.js';
|
import filterDocs from './parsefunction/filterDocs.js';
|
||||||
import sendDeleteUserMail from './parsefunction/sendDeleteUserMail.js';
|
import sendDeleteUserMail from './parsefunction/sendDeleteUserMail.js';
|
||||||
|
import resetPassword from './parsefunction/resetPassword.js';
|
||||||
|
|
||||||
// This afterSave function triggers after an object is added or updated in the specified class, allowing for post-processing logic.
|
// This afterSave function triggers after an object is added or updated in the specified class, allowing for post-processing logic.
|
||||||
Parse.Cloud.afterSave('contracts_Document', DocumentAftersave);
|
Parse.Cloud.afterSave('contracts_Document', DocumentAftersave);
|
||||||
@@ -122,3 +123,4 @@ Parse.Cloud.define('loginuser', loginUser);
|
|||||||
Parse.Cloud.define('adduser', addUser);
|
Parse.Cloud.define('adduser', addUser);
|
||||||
Parse.Cloud.define('filterdocs', filterDocs);
|
Parse.Cloud.define('filterdocs', filterDocs);
|
||||||
Parse.Cloud.define('senddeleterequest', sendDeleteUserMail);
|
Parse.Cloud.define('senddeleterequest', sendDeleteUserMail);
|
||||||
|
Parse.Cloud.define('resetpassword', resetPassword);
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
export default async function resetPassword(request) {
|
||||||
|
const userId = request.params.userId;
|
||||||
|
const newPassword = request.params.password;
|
||||||
|
|
||||||
|
if (!userId || !newPassword) {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Please provide required parameters.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!request.user) {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.user.id === userId) {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Unauthorized to reset your own password.');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. Get Admin User TenantId
|
||||||
|
const adminUserQuery = new Parse.Query('contracts_Users');
|
||||||
|
adminUserQuery.equalTo('UserId', request.user);
|
||||||
|
const adminUser = await adminUserQuery.first({ useMasterKey: true });
|
||||||
|
|
||||||
|
const tenantId = adminUser?.get('TenantId');
|
||||||
|
if (!tenantId) {
|
||||||
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Admin user tenant not found.');
|
||||||
|
}
|
||||||
|
const isAdmin =
|
||||||
|
adminUser.get('UserRole') === 'contracts_Admin' ||
|
||||||
|
adminUser.get('UserRole') === 'contracts_OrgAdmin';
|
||||||
|
if (!isAdmin) {
|
||||||
|
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Unauthorized.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Verify the user belongs to the same tenant and is not an admin
|
||||||
|
const targetUserQuery = new Parse.Query('contracts_Users');
|
||||||
|
targetUserQuery.equalTo('UserId', { __type: 'Pointer', className: '_User', objectId: userId });
|
||||||
|
targetUserQuery.equalTo('TenantId', tenantId);
|
||||||
|
targetUserQuery.notEqualTo('UserRole', 'contracts_Admin');
|
||||||
|
const targetUser = await targetUserQuery.first({ useMasterKey: true });
|
||||||
|
|
||||||
|
if (!targetUser) {
|
||||||
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found or not allowed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Update user's password
|
||||||
|
const userQuery = new Parse.Query(Parse.User);
|
||||||
|
userQuery.equalTo('objectId', userId);
|
||||||
|
const user = await userQuery.first({ useMasterKey: true });
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
user.set('password', newPassword);
|
||||||
|
await user.save(null, { useMasterKey: true });
|
||||||
|
|
||||||
|
return { status: 'success', message: 'Password has been reset.' };
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error while resetting password:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+595
-571
File diff suppressed because it is too large
Load Diff
@@ -18,8 +18,8 @@
|
|||||||
"watch": "nodemon index.js"
|
"watch": "nodemon index.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.891.0",
|
"@aws-sdk/client-s3": "^3.896.0",
|
||||||
"@aws-sdk/s3-request-presigner": "^3.891.0",
|
"@aws-sdk/s3-request-presigner": "^3.896.0",
|
||||||
"@parse/fs-files-adapter": "^3.0.0",
|
"@parse/fs-files-adapter": "^3.0.0",
|
||||||
"@parse/s3-files-adapter": "^4.2.0",
|
"@parse/s3-files-adapter": "^4.2.0",
|
||||||
"@pdf-lib/fontkit": "^1.1.1",
|
"@pdf-lib/fontkit": "^1.1.1",
|
||||||
@@ -37,8 +37,8 @@
|
|||||||
"generate-api-key": "^1.0.2",
|
"generate-api-key": "^1.0.2",
|
||||||
"googleapis": "^159.0.0",
|
"googleapis": "^159.0.0",
|
||||||
"libreoffice-convert": "^1.7.0",
|
"libreoffice-convert": "^1.7.0",
|
||||||
"mailgun.js": "^12.0.3",
|
"mailgun.js": "^12.1.0",
|
||||||
"mongodb": "^6.19.0",
|
"mongodb": "^6.20.0",
|
||||||
"multer": "^2.0.2",
|
"multer": "^2.0.2",
|
||||||
"multer-s3": "^3.0.1",
|
"multer-s3": "^3.0.1",
|
||||||
"node-forge": "^1.3.1",
|
"node-forge": "^1.3.1",
|
||||||
@@ -49,9 +49,9 @@
|
|||||||
"parse-server": "^8.2.4",
|
"parse-server": "^8.2.4",
|
||||||
"parse-server-api-mail-adapter": "^4.1.0",
|
"parse-server-api-mail-adapter": "^4.1.0",
|
||||||
"pdf-lib": "^1.17.1",
|
"pdf-lib": "^1.17.1",
|
||||||
"posthog-node": "^5.8.4",
|
"posthog-node": "^5.9.1",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"rate-limiter-flexible": "^7.3.1",
|
"rate-limiter-flexible": "^7.4.0",
|
||||||
"sharp": "^0.34.4",
|
"sharp": "^0.34.4",
|
||||||
"speakeasy": "^2.0.0",
|
"speakeasy": "^2.0.0",
|
||||||
"ws": "^8.18.3"
|
"ws": "^8.18.3"
|
||||||
@@ -59,9 +59,9 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/eslint-parser": "^7.28.4",
|
"@babel/eslint-parser": "^7.28.4",
|
||||||
"eslint": "^9.35.0",
|
"eslint": "^9.36.0",
|
||||||
"jasmine": "^5.10.0",
|
"jasmine": "^5.11.0",
|
||||||
"mongodb-runner": "^5.9.3",
|
"mongodb-runner": "^5.10.0",
|
||||||
"nodemon": "^3.1.10",
|
"nodemon": "^3.1.10",
|
||||||
"nyc": "^17.1.0",
|
"nyc": "^17.1.0",
|
||||||
"prettier": "^3.6.2"
|
"prettier": "^3.6.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user