|
@@ -13,6 +13,7 @@ import cn.iocoder.byzs.framework.common.util.object.BeanUtils;
|
|
|
import cn.iocoder.byzs.framework.security.core.LoginUser;
|
|
import cn.iocoder.byzs.framework.security.core.LoginUser;
|
|
|
import cn.iocoder.byzs.framework.tenant.core.context.TenantContextHolder;
|
|
import cn.iocoder.byzs.framework.tenant.core.context.TenantContextHolder;
|
|
|
import cn.iocoder.byzs.framework.tenant.core.util.TenantUtils;
|
|
import cn.iocoder.byzs.framework.tenant.core.util.TenantUtils;
|
|
|
|
|
+import cn.iocoder.byzs.framework.web.core.util.WebFrameworkUtils;
|
|
|
import cn.iocoder.byzs.module.system.controller.admin.oauth2.vo.token.OAuth2AccessTokenPageReqVO;
|
|
import cn.iocoder.byzs.module.system.controller.admin.oauth2.vo.token.OAuth2AccessTokenPageReqVO;
|
|
|
import cn.iocoder.byzs.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
|
|
import cn.iocoder.byzs.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
|
|
|
import cn.iocoder.byzs.module.system.dal.dataobject.oauth2.OAuth2ClientDO;
|
|
import cn.iocoder.byzs.module.system.dal.dataobject.oauth2.OAuth2ClientDO;
|
|
@@ -28,10 +29,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.Collections;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
import static cn.iocoder.byzs.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
|
import static cn.iocoder.byzs.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
|
|
import static cn.iocoder.byzs.framework.common.util.collection.CollectionUtils.convertSet;
|
|
import static cn.iocoder.byzs.framework.common.util.collection.CollectionUtils.convertSet;
|
|
@@ -63,8 +61,10 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService {
|
|
|
public OAuth2AccessTokenDO createAccessToken(Long userId, Integer userType, String clientId, List<String> scopes) {
|
|
public OAuth2AccessTokenDO createAccessToken(Long userId, Integer userType, String clientId, List<String> scopes) {
|
|
|
OAuth2ClientDO clientDO = oauth2ClientService.validOAuthClientFromCache(clientId);
|
|
OAuth2ClientDO clientDO = oauth2ClientService.validOAuthClientFromCache(clientId);
|
|
|
|
|
|
|
|
- // 删除用户之前的所有令牌,实现单点登录
|
|
|
|
|
- removeUserTokens(userId, userType);
|
|
|
|
|
|
|
+ // 删除用户之前的所有令牌,实现单点登录(默认租户用户可以多设备登录)
|
|
|
|
|
+ if (!Objects.equals(TenantContextHolder.getTenantId(), WebFrameworkUtils.DEFAULT_TENANT_ID)){
|
|
|
|
|
+ removeUserTokens(userId, userType);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// 创建刷新令牌
|
|
// 创建刷新令牌
|
|
|
OAuth2RefreshTokenDO refreshTokenDO = createOAuth2RefreshToken(userId, userType, clientDO, scopes);
|
|
OAuth2RefreshTokenDO refreshTokenDO = createOAuth2RefreshToken(userId, userType, clientDO, scopes);
|