Conversation
* main: docs: add Kubernetes deployment guide with overlays structure (iflytek#219) docs: simplify runtime script usage (iflytek#217) fix: add --public-url parameter for docker deployment (iflytek#216) chore: update .gitignore to include .codex directory (iflytek#211) organize .gitignore (iflytek#206) docs: add VitePress bilingual documentation site (iflytek#208)
|
关注一下后端单测哈。 |
|
另外看了具体的改动,感谢你把登录事务和 Swagger 访问问题一起补上。
|
|
嗯,看到了 workflow ,正在调整 |
…构造注入, 并补充单元测试, fix LocalAuthServiceTest 打挂 的问题
|
重新调整以下功能: |
|
|
||
| if (!passwordEncoder.matches(password, credential.getPasswordHash())) { | ||
| handleFailedLogin(credential); | ||
| localAuthFailedService.handleFailedLogin(credential); |
There was a problem hiding this comment.
这里把外层事务读取到的 LocalCredential 直接传入 REQUIRES_NEW 事务,并在内层通过 repository.save() 持久化。对已有 id 的实体,这里会走 merge,等价于把当前对象上的状态合并到内层持久化上下文。如果外层读取之后、内层提交之前有其他事务更新了 passwordHash、lockedUntil 等字段,这里存在覆盖这些更新的风险。建议在LocalAuthFailedService 内按 id 重新查询后只更新 failedAttempts / lockedUntil,或者改成定向 update。
|
|
||
| // Load saved username from localStorage on mount | ||
| useEffect(() => { | ||
| const saved = localStorage.getItem(REMEMBER_ME_KEY) |
There was a problem hiding this comment.
localStorage.getItem() 本身也可能抛出异常,例如存储被禁用或浏览器返回 SecurityError。当前 try/catch 只覆盖了 JSON.parse,没有覆盖读取动作本身。这里建议把整个读取过程都纳入异常处理,避免页面初始化阶段被存储异常中断。
| try { | ||
| await loginMutation.mutateAsync({ username: trimmedUsername, password }) | ||
| // Save username to localStorage if remember me is checked | ||
| if (rememberMe) { |
There was a problem hiding this comment.
这里把 remember-me 的存储操作和登录成功后的跳转放在同一个 try/catch 中。setItem / removeItem 失败时,登录请求实际上已经成功,但页面会停留在当前页并进入错误分支。建议把存储失败与登录失败分开处理,至少不要让 localStorage 异常影响成功登录后的导航。
Summary
Validation