Skip to content

Validate that password is entered upon reactivation of account #609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/i18n/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/fa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const fa: SynapseTranslationMessages = {
user_type: "نوع کاربر",
},
helper: {
password_required_for_reactivation: "برای فعالسازی مجدد حساب باید رمز عبور وارد کنید.",
admin: "مدیر سرور دارای کنترل کامل بر روی سرور و کاربران آن است.",
lock: "ممنوعیت استفاده از سرور توسط کاربر. این یک عملیات غیر مخرب است که می تواند برگردانده شود.",
password: "با تغییر رمز عبور کاربر از تمام دستگاه ها خارج می شود.",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ interface SynapseTranslationMessages extends TranslationMessages {
};
helper: {
password: string;
password_required_for_reactivation: string;
create_password: string;
lock: string;
deactivate: string;
Expand Down
1 change: 1 addition & 0 deletions src/i18n/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/i18n/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ const ru: SynapseTranslationMessages = {
},
helper: {
password: "Смена пароля завершит все сессии пользователя.",
password_required_for_reactivation: "Вы должны предоставить пароль для реактивации учётной записи.",
create_password: "Сгенерировать надёжный и безопасный пароль, используя кнопку ниже.",
deactivate: "Вы должны предоставить пароль для реактивации учётной записи.",
suspend:
Expand Down
1 change: 1 addition & 0 deletions src/i18n/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ const zh: SynapseTranslationMessages = {
},
helper: {
password: "更改密码会使用户注销所有会话。",
password_required_for_reactivation: "您必须提供一串密码来激活账户。",
create_password: "使用下面的按钮生成一个强大和安全的密码。",
deactivate: "您必须提供一串密码来激活账户。",
suspend: "您必须提供一串密码来暂停账户。",
Expand Down
32 changes: 25 additions & 7 deletions src/resources/users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down