diff --git a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java index 4b087f0e2..148f5103d 100644 --- a/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java +++ b/pigx-auth/src/main/java/com/pig4cloud/pigx/auth/endpoint/PigxTokenEndpoint.java @@ -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 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 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); } diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/ValidateCodeException.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/ValidateCodeException.java index ea5767f43..896878ea8 100644 --- a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/ValidateCodeException.java +++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/exception/ValidateCodeException.java @@ -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() {