mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 20:49:00 +08:00
♻️ Refactoring code. 退出令牌重构
This commit is contained in:
1 parent
6bb7aff4ad
commit
65604d745a
2 files changed
+16
-18
No files matched your search
@@ -124,7 +124,19 @@ public class PigxTokenEndpoint {
|
||||
}
|
||||
|
||||
String tokenValue = authHeader.replace(OAuth2AccessToken.BEARER_TYPE, StrUtil.EMPTY).trim();
|
||||
OAuth2AccessToken accessToken = tokenStore.readAccessToken(tokenValue);
|
||||
return delToken(tokenValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 令牌管理调用
|
||||
*
|
||||
* @param token token
|
||||
* @return
|
||||
*/
|
||||
@Inner
|
||||
@DeleteMapping("/{token}")
|
||||
public R<Boolean> delToken(@PathVariable("token") String token) {
|
||||
OAuth2AccessToken accessToken = tokenStore.readAccessToken(token);
|
||||
if (accessToken == null || StrUtil.isBlank(accessToken.getValue())) {
|
||||
return R.ok(Boolean.TRUE, "退出失败,token 无效");
|
||||
}
|
||||
@@ -140,21 +152,7 @@ public class PigxTokenEndpoint {
|
||||
// 清空 refresh token
|
||||
OAuth2RefreshToken refreshToken = accessToken.getRefreshToken();
|
||||
tokenStore.removeRefreshToken(refreshToken);
|
||||
return R.ok(Boolean.TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 令牌管理调用
|
||||
*
|
||||
* @param token token
|
||||
* @return
|
||||
*/
|
||||
@Inner
|
||||
@DeleteMapping("/{token}")
|
||||
public R<Boolean> delToken(@PathVariable("token") String token) {
|
||||
OAuth2AccessToken oAuth2AccessToken = tokenStore.readAccessToken(token);
|
||||
tokenStore.removeAccessToken(oAuth2AccessToken);
|
||||
return new R<>();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +174,7 @@ public class PigxTokenEndpoint {
|
||||
redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
|
||||
Page result = new Page(MapUtil.getInt(params, PaginationConstants.CURRENT), MapUtil.getInt(params, PaginationConstants.SIZE));
|
||||
result.setRecords(redisTemplate.opsForValue().multiGet(pages));
|
||||
result.setTotal((long) redisTemplate.keys(key).size());
|
||||
result.setTotal(redisTemplate.keys(key).size());
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ package com.pig4cloud.pigx.common.core.exception;
|
||||
* @author lengleng
|
||||
* @date 2018年06月22日16:22:15
|
||||
*/
|
||||
public class ValidateCodeException extends Exception {
|
||||
public class ValidateCodeException extends RuntimeException {
|
||||
private static final long serialVersionUID = -7285211528095468156L;
|
||||
|
||||
public ValidateCodeException() {
|
||||
|
||||
Reference in new issue
Block a user