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

+28
View File
@@ -92,6 +92,34 @@ def test_change_password_local_mode(client):
def test_change_password_rejects_unchanged_password(client):
"""新密码与原密码相同时应 400,且不改哈希。"""
headers = _auth_headers(client)
res = client.post(
'/api/user/change-password',
headers=headers,
json={'current_password': 'old-password', 'new_password': 'old-password'},
)
assert res.status_code == 400
assert (res.get_json() or {}).get('error', {}).get('code') == 'AUTH.PASSWORD_UNCHANGED'
user = db.session.query(User).filter_by(username='testuser').first()
assert user.check_password('old-password')
def test_change_password_local_mode_syncs_casdoor(client, monkeypatch):
client.application.config['CASDOOR_BASE_URL'] = 'http://casdoor.test'