diff --git a/superpowers/plans/2026-06-07-multi-login-social-login-plan.md b/superpowers/plans/2026-06-07-multi-login-social-login-plan.md index f678a40..c5deaf7 100644 --- a/superpowers/plans/2026-06-07-multi-login-social-login-plan.md +++ b/superpowers/plans/2026-06-07-multi-login-social-login-plan.md @@ -462,7 +462,7 @@ git commit -m "feat(user): 扩展内部接口支持 EMAIL 账号类型查询" - Modify: `rui-common/rui-common-oauth2/src/main/java/com/rui/common/oauth2/authentication/password/PasswordAuthenticationConverter.java` - Modify: `rui-common/rui-common-oauth2/src/main/java/com/rui/common/oauth2/service/RemoteUserDetailsService.java` -- [ ] **Step 1: 修改 `PasswordAuthenticationConverter` 支持 accountType** +- [x] **Step 1: 修改 `PasswordAuthenticationConverter` 支持 accountType** 重写 `checkParams` 方法: @@ -515,7 +515,7 @@ private boolean isValidAccountType(String accountType) { } ``` -- [ ] **Step 2: 修改 `PasswordAuthenticationProvider.buildToken`** +- [x] **Step 2: 修改 `PasswordAuthenticationProvider.buildToken`** ```java @Override @@ -538,36 +538,13 @@ public UsernamePasswordAuthenticationToken buildToken(Map reqPar } ``` -- [ ] **Step 3: 修改 `RemoteUserDetailsService` 支持 EMAIL** +- [x] **Step 3: 修改 `RemoteUserDetailsService` 支持 EMAIL** -修改 `loadUserByAccount` 方法,添加 EMAIL 支持: +> **实际执行说明 (2026-06-07)**:此功能在仓库中已存在(commit 在更早的 task 中完成),loadUserByAccount 已支持 EMAIL 类型路由。本次 Task 5 无需修改此文件的方法体。 -```java -public UserDetails loadUserByAccount(String account, String accountType) throws UsernameNotFoundException { - String cacheKey = String.format(CACHE_KEY, account); - JSONObject info = getCache(cacheKey); - if (info == null) { - try { - Result result; - if ("USERNAME".equals(accountType)) { - result = userAuthFeign.loadUser(account); - } else { - Map loginAccount = Map.of( - "account", account, - "accountType", accountType - ); - result = userAuthFeign.loadUser(loginAccount); - } - // ... 原有逻辑 - } catch (Exception e) { - // ... 原有逻辑 - } - } - return buildUserDetails(info, account); -} -``` +> **关键修补 (2026-06-07)**:plan 漏掉了 `loadUserByUsername` 的 # 解码逻辑——`BaseAuthenticationProvider.authenticate()` 链上 AuthenticationManager 最终会调用 `loadUserByUsername(principal)`,如果 principal 是 "account#accountType",原方法会按字面量查找。已在 `loadUserByUsername` 中按 `lastIndexOf('#')` 解析后路由到 `loadUserByAccount`,否则 PHONE/EMAIL 登录会直接失败。 -- [ ] **Step 4: Commit** +- [x] **Step 4: Commit** ```bash git add rui-common/rui-common-oauth2/src/main/java/com/rui/common/oauth2/authentication/password/