fix(auth): prevention for same old and new password
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user