|
|
|
@ -152,7 +152,7 @@ public class SysUserService implements ISysUserService {
|
|
|
|
|
throw new CredentialsException("用户不存在");
|
|
|
|
|
}
|
|
|
|
|
// 判断会话模式
|
|
|
|
|
checkSessionMode(user.getId());
|
|
|
|
|
checkSessionMode(loginPlatform,user.getId());
|
|
|
|
|
|
|
|
|
|
packSessionUser(sessionUser, user, user.getUserType(),loginPlatform, languageCode,deviceId);
|
|
|
|
|
packConfigSessionUser(sessionUser, user);
|
|
|
|
@ -163,21 +163,25 @@ public class SysUserService implements ISysUserService {
|
|
|
|
|
return sessionUser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkSessionMode(Long userId){
|
|
|
|
|
int sessionMode = RedisCacheTool.getSysConfigIntVal(CommonConstWords.CONFIG_SESSION_MODE,
|
|
|
|
|
CommonEnumUtil.SESSION_MODE.OVERWRITE.getValue());
|
|
|
|
|
if (sessionMode == CommonEnumUtil.SESSION_MODE.SEIZE.getValue()) {
|
|
|
|
|
String redisKey = CommonConstWords.SESSION_USER + ":*_" + userId;
|
|
|
|
|
List<Object> ds = redisSession.scan(redisKey);
|
|
|
|
|
private void checkSessionMode(Integer loginPlatform,Long userId){
|
|
|
|
|
int sessionMode = RedisCacheTool.getSysConfigIntVal(CommonConstWords.CONFIG_SESSION_MODE,CommonConstWords.CONFIG_SESSION_MODE_DEFAULT);
|
|
|
|
|
String redisKey;
|
|
|
|
|
if (sessionMode == CommonEnumUtil.SESSION_MODE.DEFAULT.getValue()) {
|
|
|
|
|
redisKey = CommonConstWords.SESSION_USER + ":" + loginPlatform + "_" + userId;
|
|
|
|
|
} else if (sessionMode == CommonEnumUtil.SESSION_MODE.SEIZE.getValue()) {
|
|
|
|
|
redisKey = CommonConstWords.SESSION_USER + ":*_" + userId;
|
|
|
|
|
}else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(ds)) {
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.LOGIN_EXCEPTION_LOGGED.getCode())
|
|
|
|
|
.setErrorDetail("用户已在其他设备登录,无法同时登录!")
|
|
|
|
|
.setErrorSolution("请联系管理员")
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
List<Object> ds = redisSession.scan(redisKey);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(ds)) {
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.LOGIN_EXCEPTION_LOGGED.getCode())
|
|
|
|
|
.setErrorDetail("用户已在其他设备登录,无法同时登录!")
|
|
|
|
|
.setErrorSolution("请联系管理员")
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|