Validate that password is entered upon reactivation of account (#609)
* Validate that password is entered upon reactivation of account * update readme
This commit is contained in:
parent
31356c0bdc
commit
14bc205ef2
@ -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
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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.",
|
||||
|
@ -162,6 +162,7 @@ const fa: SynapseTranslationMessages = {
|
||||
user_type: "نوع کاربر",
|
||||
},
|
||||
helper: {
|
||||
password_required_for_reactivation: "برای فعالسازی مجدد حساب باید رمز عبور وارد کنید.",
|
||||
admin: "مدیر سرور دارای کنترل کامل بر روی سرور و کاربران آن است.",
|
||||
lock: "ممنوعیت استفاده از سرور توسط کاربر. این یک عملیات غیر مخرب است که می تواند برگردانده شود.",
|
||||
password: "با تغییر رمز عبور کاربر از تمام دستگاه ها خارج می شود.",
|
||||
|
@ -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.",
|
||||
|
1
src/i18n/index.d.ts
vendored
1
src/i18n/index.d.ts
vendored
@ -161,6 +161,7 @@ interface SynapseTranslationMessages extends TranslationMessages {
|
||||
};
|
||||
helper: {
|
||||
password: string;
|
||||
password_required_for_reactivation: string;
|
||||
create_password: string;
|
||||
lock: string;
|
||||
deactivate: string;
|
||||
|
@ -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",
|
||||
|
@ -208,6 +208,7 @@ const ru: SynapseTranslationMessages = {
|
||||
},
|
||||
helper: {
|
||||
password: "Смена пароля завершит все сессии пользователя.",
|
||||
password_required_for_reactivation: "Вы должны предоставить пароль для реактивации учётной записи.",
|
||||
create_password: "Сгенерировать надёжный и безопасный пароль, используя кнопку ниже.",
|
||||
deactivate: "Вы должны предоставить пароль для реактивации учётной записи.",
|
||||
suspend:
|
||||
|
@ -193,6 +193,7 @@ const zh: SynapseTranslationMessages = {
|
||||
},
|
||||
helper: {
|
||||
password: "更改密码会使用户注销所有会话。",
|
||||
password_required_for_reactivation: "您必须提供一串密码来激活账户。",
|
||||
create_password: "使用下面的按钮生成一个强大和安全的密码。",
|
||||
deactivate: "您必须提供一串密码来激活账户。",
|
||||
suspend: "您必须提供一串密码来暂停账户。",
|
||||
|
@ -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 (
|
||||
<>
|
||||
<PasswordInput
|
||||
{...props}
|
||||
helperText={
|
||||
asManagedUserIsSelected
|
||||
? "resources.users.helper.modify_managed_user_error"
|
||||
: record
|
||||
? "resources.users.helper.password"
|
||||
: "resources.users.helper.create_password"
|
||||
}
|
||||
validate={validatePasswordOnReactivation}
|
||||
helperText={passwordHelperText}
|
||||
disabled={asManagedUserIsSelected}
|
||||
/>
|
||||
<Button
|
||||
|
Loading…
x
Reference in New Issue
Block a user