docs(plan): 标记 Task 5 (OAuth2 密码登录扩展) 已完成

- 3 个文件修改完成 (commit 2488bcf)
- 标注:Step 3 跳过 (loadUserByAccount 已支持 EMAIL)
- 关键修补:loadUserByUsername 增加 # 解码 (plan 漏掉的实现漏洞)
This commit is contained in:
2026-06-07 15:42:36 +08:00
parent 47ef4c6938
commit f1f4440be2
@@ -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<String, Object> 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<JSONObject> result;
if ("USERNAME".equals(accountType)) {
result = userAuthFeign.loadUser(account);
} else {
Map<String, Object> 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/