fix(auth): 修改密码当新密码与旧密码相同时弹出错误,不再退出登录

This commit is contained in:
sophie committed 2026-09-08 13:32:39 +08:00
1 parent 9570197378
commit 0f8b318458
18 files changed
+247 -18

No files matched your search

+3
View File
@@ -324,12 +324,15 @@ def _verify_current_password_for_change(user, current_password: str):
raise
def _sync_casdoor_password(username: str, current_password: str, new_password: str):
"""将用户自助改密同步到 Casdoor;新密码未变化原样抛出,原密码错误转为 403。"""
if not _is_casdoor_configured():
return
user_owner = _casdoor_user_owner()
try:
_casdoor_set_password(user_owner, username, current_password, new_password)
except AppError as first_error:
if first_error.code == 'AUTH.PASSWORD_UNCHANGED':
raise
if first_error.code in ('CASDOOR_INVALID_CREDENTIALS', 'AUTH.INCORRECT_CURRENT_PASSWORD'):
_raise_incorrect_current_password()
raise