Repository navigation
🐛 Bugfix: Keep current session after password change; stop false-success account deletion - #4549
Merged
Merged
Conversation
…op reporting rejected account deletion as success
jeffwu-1999
requested review from
WMC001,
YehongPan,
hhhhsc701 and
xuyaqist
as code owners
December 3, 2026 08:45
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
WMC001
approved these changes
Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
两个独立缺陷:
change_password使 token_version+1 吊销所有会话(含当前),前端只报"密码更新成功"留在原页,后续操作全部 401。authService.revoke用裸 fetch 绕过 401 拦截器,catch 只打日志、finally 无条件清本地会话、永远返回{error:null}→ 删除账号失败(401/500/网络断)时 UI 谎报"注销成功",账号实际未删。复现边界(实测确认)
POST /api/user/revoke)触发;管理员在资源管理页删他人走DELETE /api/users/{id}(fetchWithAuth,错误处理正常),不受影响。修复(产品决策:保留当前会话、吊销其它会话,GitHub/Google 式)
后端
update_password成功后:revoke_local_sessions_by_user吊销全部旧会话行(含当前,杜绝旧会话残留可刷新)→build_token_response(user_id, token_version+1)签发唯一新会话;其它设备因 ver 不匹配自然失效。错误分支(弱密码/同密码/旧密码错/CAS 并发)不吊销不签发。update_password_endpoint成功响应{message, data:{session}},对齐 signin 信封。server.js
/api/user/password加入 AUTH_INTERCEPT_ENDPOINTS,原 scope 内替换 HttpOnly cookie(不轮换 scope);PUT body 原样透传;响应 sanitized,token 不进浏览器 JS。前端
updatePassword成功用返回 expires_at 刷新本地会话存储,不登出。revoke改用 fetchWithAuth(401 走统一会话失效流程),失败返回{error};removeSessionFromStorage只在真成功时执行;useAuthenticationState.revoke失败上抛;handleDeleteAccount失败提示 revokeFailed 留在本页,成功才跳转。验证(全部实跑)
基线区分:resourceKnowledgeAuthorization 3 例失败已在干净 develop HEAD 复跑确认属既有问题,与本 PR 无关。
改动规模
13 文件 +657/-24(产品代码 7 文件,测试 6 文件)。不动 deploy/sql、workflows。