fix : 修复登陆失败,事务失效问题#317
Open
zhaieryuan wants to merge 1 commit intoiflytek:mainfrom
Open
Conversation
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.
Summary
LocalAuthFailedService,使用 @transactional(propagation = REQUIRES_NEW)
在独立事务中执行,确保即使外层登录事务回滚,失败计数和账户锁定仍能正确持久化
dirty checking 依赖外层事务
不经过代理,导致事务注解失效)
Validation
Commands run:
cd server && JDK_JAVA_OPTIONS="-XX:+EnableDynamicAgentLoading" ./mvnw test -pl skillhub-auth -am
-Dtest=LocalAuthServiceTest -Dsurefire.failIfNoSpecifiedTests=false
Tests run: 12, Failures: 0, Errors: 0, Skipped: 0 — BUILD SUCCESS
Risk
Notes
不生效,导致失败计数未持久化
涉及文件
┌───────────────────────────────────────────────────────────────┬────────────────────────────────┐
│ 文件 │ 变更 │
├───────────────────────────────────────────────────────────────┼────────────────────────────────┤
│ server/skillhub-auth/src/main/java/.../LocalAuthFailedService │ 新增 — │
│ .java │ 独立事务处理失败登录计数 │
├───────────────────────────────────────────────────────────────┼────────────────────────────────┤
│ │ 注入 │
│ server/skillhub-auth/src/main/java/.../LocalAuthService.java │ LocalAuthFailedService,login │
│ │ 方法中调用替代原内联方法 │
├───────────────────────────────────────────────────────────────┼────────────────────────────────┤
│ server/skillhub-auth/src/main/java/.../LocalCredentialReposit │ 新增 updateFailedAttemptsAndLo │
│ ory.java │ ckedUntil JPQL 方法 │
├───────────────────────────────────────────────────────────────┼────────────────────────────────┤
│ │ 适配新架构:mock LocalAuthFail │
│ server/skillhub-auth/src/test/.../LocalAuthServiceTest.java │ edService,断言改为 verify │
│ │ 调用 │
└───────────────────────────────────────────────────────────────┴────────────────────────────────┘