修改登录去除多余部分
This commit is contained in:
@@ -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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user