Browse Source

获取用户sessionId修改

master
WendyYang 1 year ago
parent
commit
26ef523dc1
1 changed files with 4 additions and 18 deletions
  1. +4
    -18
      pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthManage.java

+ 4
- 18
pmapi/src/main/java/com/ningdatech/pmapi/user/manage/UserAuthManage.java View File

@@ -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<String> sessionIds = getSessionIds(userFullInfo);
List<String> sessionIds = getSessionIds(userFullInfo.getUsername());
if (sessionIds.isEmpty()) {
return;
}
@@ -50,26 +49,13 @@ public class UserAuthManage {
});
}

private List<String> getSessionIds(UserFullInfoDTO userFullInfo) {
List<String> 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<String> getSessionIds(String username) {
return new ArrayList<>(redisSessionRepository.findByPrincipalName(username).keySet());
}

public void kickOff(Long userId) {
UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfo(userId);
List<String> sessionIds = getSessionIds(userFullInfo);
List<String> sessionIds = getSessionIds(userFullInfo.getUsername());
sessionIds.forEach(redisSessionRepository::deleteById);
}



Loading…
Cancel
Save