|
@@ -400,7 +400,10 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
}
|
|
}
|
|
if (all) {
|
|
if (all) {
|
|
for (Platform p : Platform.values()) {
|
|
for (Platform p : Platform.values()) {
|
|
- Set<String> roleNames = authBean.getRoleList().stream().map(s -> s.getName()).collect(Collectors.toSet());
|
|
|
|
|
|
+ Set<String> roleNamesSet = authBean.getRoleList().stream().map(s -> s.getName()).collect(Collectors.toSet());
|
|
|
|
+ List<String> roleNames = new ArrayList<>();
|
|
|
|
+ roleNames.addAll(roleNamesSet);
|
|
|
|
+ Collections.sort(roleNames);
|
|
String sessionId = SessionUtil.digest(userId, Math.abs(roleNames.toString().hashCode()), p.name());
|
|
String sessionId = SessionUtil.digest(userId, Math.abs(roleNames.toString().hashCode()), p.name());
|
|
tbSessionService.removeById(sessionId);
|
|
tbSessionService.removeById(sessionId);
|
|
redisUtil.deleteUserSession(sessionId);
|
|
redisUtil.deleteUserSession(sessionId);
|
|
@@ -435,10 +438,12 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
while (max <= size) {
|
|
while (max <= size) {
|
|
List<UserRoleNameResult> userRoleNameResultList = sysUserService.selectRoleNames(userIds.subList(min, max));
|
|
List<UserRoleNameResult> userRoleNameResultList = sysUserService.selectRoleNames(userIds.subList(min, max));
|
|
for (UserRoleNameResult userRoleNameResult : userRoleNameResultList) {
|
|
for (UserRoleNameResult userRoleNameResult : userRoleNameResultList) {
|
|
|
|
+ List<String> roleNames = Arrays.asList(userRoleNameResult.getRoleNames().split(","));
|
|
|
|
+ Collections.sort(roleNames);
|
|
for (Platform p : Platform.values()) {
|
|
for (Platform p : Platform.values()) {
|
|
String sessionId = null;
|
|
String sessionId = null;
|
|
try {
|
|
try {
|
|
- sessionId = SessionUtil.digest(userRoleNameResult.getUserId(), Math.abs(Arrays.asList(userRoleNameResult.getRoleNames().split(",")).toString().hashCode()), p.name());
|
|
|
|
|
|
+ sessionId = SessionUtil.digest(userRoleNameResult.getUserId(), Math.abs(roleNames.toString().hashCode()), p.name());
|
|
} catch (NoSuchAlgorithmException e) {
|
|
} catch (NoSuchAlgorithmException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
@@ -909,15 +914,18 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
String token = SystemConstant.getUuid();
|
|
String token = SystemConstant.getUuid();
|
|
commonCacheService.userCache(sysUser.getId());
|
|
commonCacheService.userCache(sysUser.getId());
|
|
//添加用户会话缓存
|
|
//添加用户会话缓存
|
|
- Set<String> roleNames = new HashSet<>(), roleTypes = new HashSet<>();
|
|
|
|
|
|
+ Set<String> roleNamesSet = new HashSet<>(), roleTypes = new HashSet<>();
|
|
List<RoleResult> roleSource = new ArrayList<>();
|
|
List<RoleResult> roleSource = new ArrayList<>();
|
|
for (SysRole s : authBean.getRoleList()) {
|
|
for (SysRole s : authBean.getRoleList()) {
|
|
- roleNames.add(s.getName());
|
|
|
|
|
|
+ roleNamesSet.add(s.getName());
|
|
if (Objects.isNull(s.getSource()) && Objects.nonNull(s.getType())) {
|
|
if (Objects.isNull(s.getSource()) && Objects.nonNull(s.getType())) {
|
|
roleTypes.add(s.getType().name());
|
|
roleTypes.add(s.getType().name());
|
|
}
|
|
}
|
|
roleSource.add(Objects.nonNull(s.getType()) ? new RoleResult(s.getId(), s.getName(), s.getType().name(), s.getSource()) : new RoleResult(s.getId(), s.getName(), s.getSource()));
|
|
roleSource.add(Objects.nonNull(s.getType()) ? new RoleResult(s.getId(), s.getName(), s.getType().name(), s.getSource()) : new RoleResult(s.getId(), s.getName(), s.getSource()));
|
|
}
|
|
}
|
|
|
|
+ List<String> roleNames = new ArrayList<>();
|
|
|
|
+ roleNames.addAll(roleNamesSet);
|
|
|
|
+ Collections.sort(roleNames);
|
|
String sessionId = SessionUtil.digest(sysUser.getId(), Math.abs(roleNames.toString().hashCode()), platform.name());
|
|
String sessionId = SessionUtil.digest(sysUser.getId(), Math.abs(roleNames.toString().hashCode()), platform.name());
|
|
//TODO 测试用
|
|
//TODO 测试用
|
|
// String test = SignatureEntityTest.build(SignatureType.TOKEN, sessionId, token);
|
|
// String test = SignatureEntityTest.build(SignatureType.TOKEN, sessionId, token);
|
|
@@ -928,8 +936,8 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
tbSessionService.saveOrUpdate(tbSession);
|
|
tbSessionService.saveOrUpdate(tbSession);
|
|
redisUtil.setUserSession(sessionId, tbSession, expireTime.getExpireSeconds());
|
|
redisUtil.setUserSession(sessionId, tbSession, expireTime.getExpireSeconds());
|
|
|
|
|
|
-// LoginResult loginResult = new LoginResult(sysUser, sessionId, test, Objects.nonNull(roleTypes) && roleTypes.size() > 0 ? roleTypes : roleNames, appSource, roleSource);
|
|
|
|
- LoginResult loginResult = new LoginResult(sysUser, sessionId, token, Objects.nonNull(roleTypes) && roleTypes.size() > 0 ? roleTypes : roleNames, appSource, roleSource);
|
|
|
|
|
|
+// LoginResult loginResult = new LoginResult(sysUser, sessionId, test, Objects.nonNull(roleTypes) && roleTypes.size() > 0 ? roleTypes : roleNamesSet, appSource, roleSource);
|
|
|
|
+ LoginResult loginResult = new LoginResult(sysUser, sessionId, token, Objects.nonNull(roleTypes) && roleTypes.size() > 0 ? roleTypes : roleNamesSet, appSource, roleSource);
|
|
loginResult.setSchoolInfo(Objects.nonNull(authBean.getSchool()) ? loginResult.new SchoolNativeBean(authBean.getSchool()) : null);
|
|
loginResult.setSchoolInfo(Objects.nonNull(authBean.getSchool()) ? loginResult.new SchoolNativeBean(authBean.getSchool()) : null);
|
|
loginResult.setOrgInfo(Objects.nonNull(authBean.getOrg()) ? loginResult.new OrgNativeBean(authBean.getOrg()) : null);
|
|
loginResult.setOrgInfo(Objects.nonNull(authBean.getOrg()) ? loginResult.new OrgNativeBean(authBean.getOrg()) : null);
|
|
loginResult.setTime(System.currentTimeMillis());
|
|
loginResult.setTime(System.currentTimeMillis());
|