修改登录去除多余部分

This commit is contained in:
sh
2026-06-25 18:22:08 +08:00
parent b6959ce22b
commit 6229d39203

View File

@@ -214,23 +214,12 @@ public class OauthLoginHlwService {
* (关键:用本地用户名构建认证令牌,无需密码,因为门户已完成身份校验) * (关键:用本地用户名构建认证令牌,无需密码,因为门户已完成身份校验)
*/ */
private Authentication authenticateLocalUser(String localUsername) { private Authentication authenticateLocalUser(String localUsername) {
Authentication authentication = null;
try { try {
UserDetails userDetails = userDetailsService.loadUserByUsername(localUsername); UserDetails userDetails = userDetailsService.loadUserByUsername(localUsername);
return new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
authentication = new UsernamePasswordAuthenticationToken(
userDetails,
null, // 密码为 null彻底绕过 Spring Security 的密码校验
userDetails.getAuthorities()
);
AuthenticationContextHolder.setContext(authentication);
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("本地用户认证失败:" + e.getMessage()); throw new ServiceException("本地用户认证失败:" + e.getMessage());
} finally {
AuthenticationContextHolder.clearContext();
} }
return authentication;
} }
/** /**