diff --git a/README.md b/README.md index 06d3688..afb4c23 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ The following changes are already implemented: * 🌐 [Configurable CORS Credentials](https://github.com/etkecc/synapse-admin/pull/456) * [Do not check homeserver URL during typing in the login form](https://github.com/etkecc/synapse-admin/pull/585) * [Improve user account status toggles](https://github.com/etkecc/synapse-admin/pull/608) +* [Validate that password is entered upon reactivation of account](https://github.com/etkecc/synapse-admin/pull/609) #### exclusive for [etke.cc](https://etke.cc) customers diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 4737486..08f0085 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -204,6 +204,7 @@ const de: SynapseTranslationMessages = { }, helper: { password: "Durch die Änderung des Passworts wird der Benutzer von allen Sitzungen abgemeldet.", + password_required_for_reactivation: "Sie müssen ein Passwort angeben, um ein Konto wieder zu aktivieren.", create_password: "Generiere ein starkes und sicheres Passwort mit dem Button unten.", deactivate: "Sie müssen ein Passwort angeben, um ein Konto wieder zu aktivieren.", suspend: diff --git a/src/i18n/en.ts b/src/i18n/en.ts index ea01dea..bad68cb 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -171,6 +171,7 @@ const en: SynapseTranslationMessages = { }, helper: { password: "Changing password will log user out of all sessions.", + password_required_for_reactivation: "You must provide a password to re-activate an account.", create_password: "Generate a strong and secure password using the button below.", lock: "Prevent the user from usefully using their account. This is a non-destructive action that can be reversed.", deactivate: "You must provide a password to re-activate an account.", diff --git a/src/i18n/fa.ts b/src/i18n/fa.ts index 754c63c..cd5d80f 100644 --- a/src/i18n/fa.ts +++ b/src/i18n/fa.ts @@ -162,6 +162,7 @@ const fa: SynapseTranslationMessages = { user_type: "نوع کاربر", }, helper: { + password_required_for_reactivation: "برای فعالسازی مجدد حساب باید رمز عبور وارد کنید.", admin: "مدیر سرور دارای کنترل کامل بر روی سرور و کاربران آن است.", lock: "ممنوعیت استفاده از سرور توسط کاربر. این یک عملیات غیر مخرب است که می تواند برگردانده شود.", password: "با تغییر رمز عبور کاربر از تمام دستگاه ها خارج می شود.", diff --git a/src/i18n/fr.ts b/src/i18n/fr.ts index 0488c4a..645a3c6 100644 --- a/src/i18n/fr.ts +++ b/src/i18n/fr.ts @@ -170,6 +170,7 @@ const fr: SynapseTranslationMessages = { }, helper: { password: "Changer le mot de passe déconnectera l'utilisateur de toutes les sessions.", + password_required_for_reactivation: "Vous devez fournir un mot de passe pour réactiver le compte.", create_password: "Générer un mot de passe fort et sécurisé en utilisant le bouton ci-dessous.", deactivate: "Vous devrez fournir un mot de passe pour réactiver le compte.", suspend: "L'utilisateur sera suspendu jusqu'à ce que vous le réactiviez.", diff --git a/src/i18n/index.d.ts b/src/i18n/index.d.ts index 325ecba..33b671b 100644 --- a/src/i18n/index.d.ts +++ b/src/i18n/index.d.ts @@ -161,6 +161,7 @@ interface SynapseTranslationMessages extends TranslationMessages { }; helper: { password: string; + password_required_for_reactivation: string; create_password: string; lock: string; deactivate: string; diff --git a/src/i18n/it.ts b/src/i18n/it.ts index 7300bea..dbf15cf 100644 --- a/src/i18n/it.ts +++ b/src/i18n/it.ts @@ -163,6 +163,7 @@ const it: SynapseTranslationMessages = { }, helper: { password: "Cambiando la password l'utente verrà disconnesso da tutte le sessioni attive.", + password_required_for_reactivation: "Devi fornire una password per riattivare l'account.", create_password: "Genera una password forte e sicura utilizzando il pulsante sottostante.", deactivate: "Devi fornire una password per riattivare l'account.", suspend: "Sospendi l'utente", diff --git a/src/i18n/ru.ts b/src/i18n/ru.ts index f1d49f7..351ea5a 100644 --- a/src/i18n/ru.ts +++ b/src/i18n/ru.ts @@ -208,6 +208,7 @@ const ru: SynapseTranslationMessages = { }, helper: { password: "Смена пароля завершит все сессии пользователя.", + password_required_for_reactivation: "Вы должны предоставить пароль для реактивации учётной записи.", create_password: "Сгенерировать надёжный и безопасный пароль, используя кнопку ниже.", deactivate: "Вы должны предоставить пароль для реактивации учётной записи.", suspend: diff --git a/src/i18n/zh.ts b/src/i18n/zh.ts index 8c36c32..a516eee 100644 --- a/src/i18n/zh.ts +++ b/src/i18n/zh.ts @@ -193,6 +193,7 @@ const zh: SynapseTranslationMessages = { }, helper: { password: "更改密码会使用户注销所有会话。", + password_required_for_reactivation: "您必须提供一串密码来激活账户。", create_password: "使用下面的按钮生成一个强大和安全的密码。", deactivate: "您必须提供一串密码来激活账户。", suspend: "您必须提供一串密码来暂停账户。", diff --git a/src/resources/users.tsx b/src/resources/users.tsx index 3cb6a05..57a7b3f 100644 --- a/src/resources/users.tsx +++ b/src/resources/users.tsx @@ -434,6 +434,7 @@ const UserBooleanInput = props => { const UserPasswordInput = props => { const record = useRecordContext(); let asManagedUserIsSelected = false; + const translate = useTranslate(); // Get form context to update field value const form = useFormContext(); @@ -446,17 +447,34 @@ const UserPasswordInput = props => { form.setValue("password", password, { shouldDirty: true }); }; + // Get the current deactivated state and the original value + const deactivated = form.watch("deactivated"); + const deactivatedFromRecord = record?.deactivated; + + // Custom validation for reactivation case + const validatePasswordOnReactivation = value => { + if (deactivatedFromRecord === true && deactivated === false && !value) { + return translate("resources.users.helper.password_required_for_reactivation"); + } + return undefined; + }; + + let passwordHelperText = "resources.users.helper.create_password"; + + if (asManagedUserIsSelected) { + passwordHelperText = "resources.users.helper.modify_managed_user_error"; + } else if (deactivatedFromRecord === true && deactivated === false) { + passwordHelperText = "resources.users.helper.password_required_for_reactivation"; + } else if (record) { + passwordHelperText = "resources.users.helper.password"; + } + return ( <>