mirror of https://gitee.com/stylefeng/roses
【8.1.9】【sys】获取用户的状态增加自动解锁功能
parent
cc09e43f9b
commit
c88622cec4
|
@ -219,6 +219,7 @@ public class LoginService {
|
|||
Integer loginErrorCount = loginErrorCountCacheApi.get(loginRequest.getAccount());
|
||||
if (loginErrorCount != null && loginErrorCount >= LoginConfigExpander.getMaxErrorLoginCount()) {
|
||||
// 修改用户状态为锁定
|
||||
// 【2024年7月12日新增,默认锁定1天】
|
||||
sysUserServiceApi.lockUserStatus(loginRequest.getTenantCode(), loginRequest.getAccount());
|
||||
throw new AuthException(AuthExceptionEnum.LOGIN_LOCKED);
|
||||
}
|
||||
|
|
|
@ -484,21 +484,31 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
public UserValidateDTO getUserLoginValidateDTO(Long tenantId, String account) {
|
||||
LambdaQueryWrapper<SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sysUserLambdaQueryWrapper.eq(SysUser::getAccount, account);
|
||||
sysUserLambdaQueryWrapper.select(SysUser::getPassword, SysUser::getPasswordSalt, SysUser::getStatusFlag, SysUser::getUserId);
|
||||
sysUserLambdaQueryWrapper.select(SysUser::getPassword, SysUser::getPasswordSalt, SysUser::getStatusFlag, SysUser::getFreezeDeadlineTime, SysUser::getUserId);
|
||||
|
||||
// 单独填充租户id
|
||||
SysUser sysUserServiceOne;
|
||||
try {
|
||||
TenantIdHolder.set(tenantId);
|
||||
sysUserServiceOne = this.getOne(sysUserLambdaQueryWrapper, false);
|
||||
|
||||
// 用户查询不到,提示账号密码错误
|
||||
if (sysUserServiceOne == null) {
|
||||
throw new ServiceException(SysUserExceptionEnum.ACCOUNT_NOT_EXIST);
|
||||
}
|
||||
|
||||
// 判断用户状态是否被临时冻结,如果超过了临时冻结时间,将用户状态改为正常态
|
||||
if (UserStatusEnum.TEMP_FREEZE.getCode().equals(sysUserServiceOne.getStatusFlag())) {
|
||||
Date freezeDeadlineTime = sysUserServiceOne.getFreezeDeadlineTime();
|
||||
if (freezeDeadlineTime != null && freezeDeadlineTime.before(new Date())) {
|
||||
sysUserServiceOne.setStatusFlag(UserStatusEnum.ENABLE.getCode());
|
||||
this.updateById(sysUserServiceOne);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
TenantIdHolder.remove();
|
||||
}
|
||||
|
||||
if (sysUserServiceOne == null) {
|
||||
throw new ServiceException(SysUserExceptionEnum.ACCOUNT_NOT_EXIST);
|
||||
}
|
||||
|
||||
return new UserValidateDTO(sysUserServiceOne.getUserId(), sysUserServiceOne.getPassword(), sysUserServiceOne.getPasswordSalt(), sysUserServiceOne.getStatusFlag(), tenantId, account);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue