fix(auth): prevention for same old and new password
LocationBasedServices/smartguide/pipeline/head This commit looks good

This commit is contained in:
Mats Paul Tončik
2026-07-03 13:14:05 +02:00
parent 0b9f325045
commit cac2d81b5c
2 changed files with 25 additions and 0 deletions
+10
View File
@@ -1080,6 +1080,16 @@ def change_password(
detail="Current password is incorrect.",
)
if current_password == new_password:
logger.warning(
"Password change failed: new password is the same as the current password for account %s",
account.id,
)
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="New password cannot be the same as the current password.",
)
account.password_hash = _hash_password(new_password)
account.epoch += 1
@@ -120,6 +120,21 @@ export class AccountComponent {
return null;
});
validate(schemaPath.newPassword, ({ value }) => {
const oldPassword = this.changePasswordModel().oldPassword.trim();
const newPassword = value().trim();
if (oldPassword && newPassword && oldPassword === newPassword) {
return {
kind: 'passwordSameAsOld',
message:
'Neues Passwort darf nicht dasselbe wie das alte Passwort sein.',
};
}
return null;
});
},
{
submission: {