From 26ef523dc10150ce0038f23497d68dccf4a51d90 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 5 May 2023 17:13:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7sessionId?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/user/manage/UserAuthManage.java | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthManage.java index 0d6a3ad..f5c820d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthManage.java @@ -1,7 +1,6 @@ package com.ningdatech.pmapi.user.manage; import com.ningdatech.pmapi.common.helper.UserInfoHelper; -import com.ningdatech.pmapi.common.util.StrUtils; import com.ningdatech.pmapi.user.convert.UserInfoConvertor; import com.ningdatech.pmapi.user.security.auth.credential.CredentialAuthToken; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; @@ -34,7 +33,7 @@ public class UserAuthManage { @SuppressWarnings({"rawtypes", "unchecked"}) public void refreshSession(Long userId) { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); - List sessionIds = getSessionIds(userFullInfo); + List sessionIds = getSessionIds(userFullInfo.getUsername()); if (sessionIds.isEmpty()) { return; } @@ -50,26 +49,13 @@ public class UserAuthManage { }); } - private List getSessionIds(UserFullInfoDTO userFullInfo) { - List sessionIds = new ArrayList<>(); - String identifier = userFullInfo.getIdentifier(); - if (StrUtils.isNotBlank(identifier)) { - sessionIds.addAll(redisSessionRepository.findByPrincipalName(identifier).keySet()); - } - String mobile = userFullInfo.getMobile(); - if (StrUtils.isNotBlank(mobile)) { - sessionIds.addAll(redisSessionRepository.findByPrincipalName(mobile).keySet()); - } - Long accountId = userFullInfo.getAccountId(); - if (accountId != null) { - sessionIds.addAll(redisSessionRepository.findByPrincipalName(accountId.toString()).keySet()); - } - return sessionIds; + private List getSessionIds(String username) { + return new ArrayList<>(redisSessionRepository.findByPrincipalName(username).keySet()); } public void kickOff(Long userId) { UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId); - List sessionIds = getSessionIds(userFullInfo); + List sessionIds = getSessionIds(userFullInfo.getUsername()); sessionIds.forEach(redisSessionRepository::deleteById); }