Rifiuta il riuso della password attuale in cambio e reset.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-08 11:31:47 +02:00
co-authored by Cursor
parent 53449c5d3c
commit dd9901519a
17 changed files with 60 additions and 0 deletions
@@ -24,6 +24,11 @@ module Admin
return render :edit, status: :unprocessable_entity
end
if PasswordComplexity.same_as_current?(current_admin_account, params[:password])
flash.now[:alert] = t("admin.flash.password_same_as_current")
return render :edit, status: :unprocessable_entity
end
if current_admin_account.update(password: params[:password])
redirect_to admin_root_path, notice: t("admin.flash.password_updated")
else
@@ -51,6 +51,7 @@ module Api
when :too_long then "Password cannot exceed 72 characters"
when :too_weak
"Password must include at least 3 of: lowercase, uppercase, number, symbol"
when :same_as_current then "New password must be different from the current password"
when :mismatch then "Passwords do not match"
else "Unable to update password"
end
@@ -40,6 +40,12 @@ module Public
return render :edit, status: :unprocessable_entity
end
if PasswordComplexity.same_as_current?(@user, params[:password])
flash.now[:alert] = t("flash.password_resets.password_same_as_current")
@token = params[:token]
return render :edit, status: :unprocessable_entity
end
@user.update!(password: params[:password])
@user.clear_password_reset!
redirect_to public_login_path, notice: t("flash.password_resets.password_updated")