|
@@ -21,7 +21,7 @@ import javax.annotation.Resource;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.List;
|
|
|
|
|
|
-import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
|
|
|
/**
|
|
@@ -58,13 +58,13 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService {
|
|
|
// 查询访问令牌
|
|
|
OAuth2RefreshTokenDO refreshTokenDO = oauth2RefreshTokenMapper.selectByRefreshToken(refreshToken);
|
|
|
if (refreshTokenDO == null) {
|
|
|
- throw exception(GlobalErrorCodeConstants.BAD_REQUEST, "无效的刷新令牌");
|
|
|
+ throw exception0(GlobalErrorCodeConstants.BAD_REQUEST.getCode(), "无效的刷新令牌");
|
|
|
}
|
|
|
|
|
|
// 校验 Client 匹配
|
|
|
OAuth2ClientDO clientDO = oauth2ClientService.validOAuthClientFromCache(clientId);
|
|
|
if (ObjectUtil.notEqual(clientId, refreshTokenDO.getClientId())) {
|
|
|
- throw exception(GlobalErrorCodeConstants.BAD_REQUEST, "刷新令牌的客户端编号不正确");
|
|
|
+ throw exception0(GlobalErrorCodeConstants.BAD_REQUEST.getCode(), "刷新令牌的客户端编号不正确");
|
|
|
}
|
|
|
|
|
|
// 移除相关的访问令牌
|
|
@@ -77,7 +77,7 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService {
|
|
|
// 已过期的情况下,删除刷新令牌
|
|
|
if (DateUtils.isExpired(refreshTokenDO.getExpiresTime())) {
|
|
|
oauth2AccessTokenMapper.deleteById(refreshTokenDO.getId());
|
|
|
- throw exception(GlobalErrorCodeConstants.UNAUTHORIZED, "刷新令牌已过期");
|
|
|
+ throw exception0(GlobalErrorCodeConstants.UNAUTHORIZED.getCode(), "刷新令牌已过期");
|
|
|
}
|
|
|
|
|
|
// 创建访问令牌
|
|
@@ -105,10 +105,10 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService {
|
|
|
public OAuth2AccessTokenDO checkAccessToken(String accessToken) {
|
|
|
OAuth2AccessTokenDO accessTokenDO = getAccessToken(accessToken);
|
|
|
if (accessTokenDO == null) {
|
|
|
- throw exception(GlobalErrorCodeConstants.UNAUTHORIZED, "访问令牌不存在");
|
|
|
+ throw exception0(GlobalErrorCodeConstants.UNAUTHORIZED.getCode(), "访问令牌不存在");
|
|
|
}
|
|
|
if (DateUtils.isExpired(accessTokenDO.getExpiresTime())) {
|
|
|
- throw exception(GlobalErrorCodeConstants.UNAUTHORIZED, "访问令牌已过期");
|
|
|
+ throw exception0(GlobalErrorCodeConstants.UNAUTHORIZED.getCode(), "访问令牌已过期");
|
|
|
}
|
|
|
return accessTokenDO;
|
|
|
}
|