Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
01d1aa97
Commit
01d1aa97
authored
Mar 03, 2021
by
Zheng Jie
Browse files
[代码优化](v2.6):加入第三方系统获取Token的方式
close
https://github.com/elunez/eladmin/issues/585
parent
3f129e8e
Changes
1
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java
View file @
01d1aa97
...
@@ -89,7 +89,10 @@ public class AuthorizationController {
...
@@ -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
();
// 保存在线信息
// 保存在线信息
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment