优化 yudao-sso-demo-by-code 的代码
parent
f634ecf7c3
commit
6be30c0887
|
@ -52,7 +52,7 @@ public class AuthController {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/logout")
|
@PostMapping("/logout")
|
||||||
public CommonResult<Boolean> logout(HttpServletRequest request) {
|
public CommonResult<Boolean> logout(HttpServletRequest request) {
|
||||||
String token = SecurityUtils.obtainAuthorization(request, "Authentication");
|
String token = SecurityUtils.obtainAuthorization(request, "Authorization");
|
||||||
if (StrUtil.isNotBlank(token)) {
|
if (StrUtil.isNotBlank(token)) {
|
||||||
return oauth2Client.revokeToken(token);
|
return oauth2Client.revokeToken(token);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class TokenAuthenticationFilter extends OncePerRequestFilter {
|
||||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
|
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
|
||||||
FilterChain filterChain) throws ServletException, IOException {
|
FilterChain filterChain) throws ServletException, IOException {
|
||||||
// 1. 获得访问令牌
|
// 1. 获得访问令牌
|
||||||
String token = SecurityUtils.obtainAuthorization(request, "Authentication");
|
String token = SecurityUtils.obtainAuthorization(request, "Authorization");
|
||||||
if (StringUtils.hasText(token)) {
|
if (StringUtils.hasText(token)) {
|
||||||
// 2. 基于 token 构建登录用户
|
// 2. 基于 token 构建登录用户
|
||||||
LoginUser loginUser = buildLoginUserByToken(token);
|
LoginUser loginUser = buildLoginUserByToken(token);
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
url: "http://127.0.0.1:18080/user/update?nickname=" + nickname,
|
url: "http://127.0.0.1:18080/user/update?nickname=" + nickname,
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
'Authentication': 'Bearer ' + accessToken
|
'Authorization': 'Bearer ' + accessToken
|
||||||
},
|
},
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
if (result.code !== 0) {
|
if (result.code !== 0) {
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
url: "http://127.0.0.1:18080/auth/logout",
|
url: "http://127.0.0.1:18080/auth/logout",
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Authentication': 'Bearer ' + accessToken
|
'Authorization': 'Bearer ' + accessToken
|
||||||
},
|
},
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
if (result.code !== 0) {
|
if (result.code !== 0) {
|
||||||
|
@ -120,7 +120,7 @@
|
||||||
url: "http://127.0.0.1:18080/user/get",
|
url: "http://127.0.0.1:18080/user/get",
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Authentication': 'Bearer ' + accessToken
|
'Authorization': 'Bearer ' + accessToken
|
||||||
},
|
},
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
if (result.code !== 0) {
|
if (result.code !== 0) {
|
||||||
|
|
Loading…
Reference in New Issue