[代码优化](v2.6):加入第三方系统获取Token的方式

close https://github.com/elunez/eladmin/issues/585
pull/605/head^2
Zheng Jie 2021-03-03 17:40:22 +08:00
parent 3f129e8e85
commit 01d1aa9721
1 changed files with 4 additions and 1 deletions

View File

@ -89,7 +89,10 @@ public class AuthorizationController {
new UsernamePasswordAuthenticationToken(authUser.getUsername(), password); new UsernamePasswordAuthenticationToken(authUser.getUsername(), password);
Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken); Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken);
SecurityContextHolder.getContext().setAuthentication(authentication); SecurityContextHolder.getContext().setAuthentication(authentication);
// 生成令牌 // 生成令牌与第三方系统获取令牌方式
// UserDetails userDetails = userDetailsService.loadUserByUsername(userInfo.getUsername());
// Authentication authentication = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());
// SecurityContextHolder.getContext().setAuthentication(authentication);
String token = tokenProvider.createToken(authentication); String token = tokenProvider.createToken(authentication);
final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal(); final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal();
// 保存在线信息 // 保存在线信息