会话模式配置-调整默认模式

yun-zuoyi
汪云昊 5 years ago
parent 5361c81c3d
commit 5a432554d0

@ -161,7 +161,11 @@ public class WhiteController extends CoreBaseController {
ValidatorBean.checkNotNull(loginName,"用户名不能为空");
ValidatorBean.checkNotNull(loginPwd,"密码不能为空");
ValidatorBean.checkNotNull(languageCode,"语言不能为空");
logout();
int sessionMode = RedisCacheTool.getSysConfigIntVal(CommonConstWords.CONFIG_SESSION_MODE, CommonConstWords.CONFIG_SESSION_MODE_DEFAULT);
if (sessionMode != CommonEnumUtil.SESSION_MODE.SEIZE.getValue()) {
logout();
}
SessionUser user = userService.queryUserLogin(loginName.trim(), loginPwd.trim(), languageCode, getLoginPlatform().getValue(),deviceId);

@ -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();
}
}

Loading…
Cancel
Save