|
@@ -160,18 +160,15 @@ public class SysAuthServiceImpl implements SysAuthService {
|
|
sysUserInfoDao.updateById(sysUserInfo);
|
|
sysUserInfoDao.updateById(sysUserInfo);
|
|
|
|
|
|
// [系统配置] 系统用户默认登录过期时间(小时)
|
|
// [系统配置] 系统用户默认登录过期时间(小时)
|
|
- Integer SYSTEM_LOGIN_DURATION_DEFAULT = Convert.toInt(sysCommonService.getCommonByTag("SYSTEM_LOGIN_DURATION_DEFAULT"));
|
|
|
|
|
|
+ Integer SYSTEM_USER_LOGIN_DURATION_DEFAULT = Convert.toInt(sysCommonService.getCommonByTag("SYSTEM_USER_LOGIN_DURATION_DEFAULT"));
|
|
// 将小时转换为毫秒
|
|
// 将小时转换为毫秒
|
|
- Long DEFAULT_MILLISECONDS = SYSTEM_LOGIN_DURATION_DEFAULT * DateUnit.HOUR.getMillis();
|
|
|
|
|
|
+ Long DEFAULT_MILLISECONDS = SYSTEM_USER_LOGIN_DURATION_DEFAULT * DateUnit.HOUR.getMillis();
|
|
// 7天 (转毫秒)
|
|
// 7天 (转毫秒)
|
|
Long SEVEN_DAY_MILLISECONDS = 7L * 24 * 60 * 60 * 1000;
|
|
Long SEVEN_DAY_MILLISECONDS = 7L * 24 * 60 * 60 * 1000;
|
|
|
|
|
|
Long token_duration_milliseconds = (is_remember != null && is_remember.equals(1)) ? SEVEN_DAY_MILLISECONDS : DEFAULT_MILLISECONDS;
|
|
Long token_duration_milliseconds = (is_remember != null && is_remember.equals(1)) ? SEVEN_DAY_MILLISECONDS : DEFAULT_MILLISECONDS;
|
|
Integer token_duration_hours = Convert.toInt(token_duration_milliseconds / 3600000L);
|
|
Integer token_duration_hours = Convert.toInt(token_duration_milliseconds / 3600000L);
|
|
|
|
|
|
- System.out.println("token_duration_milliseconds = " + token_duration_milliseconds);
|
|
|
|
- System.out.println("token_duration_hours = " + token_duration_hours);
|
|
|
|
-
|
|
|
|
Date token_expiration = new Date((new Date()).getTime() + token_duration_milliseconds);
|
|
Date token_expiration = new Date((new Date()).getTime() + token_duration_milliseconds);
|
|
sysUserInfo.setToken_expiration(DateUtil.format(token_expiration, "yyyy-MM-dd HH:mm:ss"));
|
|
sysUserInfo.setToken_expiration(DateUtil.format(token_expiration, "yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
|
@@ -277,6 +274,12 @@ public class SysAuthServiceImpl implements SysAuthService {
|
|
@Transactional
|
|
@Transactional
|
|
public Map<String, Object> register(SysUserDTO sysUserDTO) {
|
|
public Map<String, Object> register(SysUserDTO sysUserDTO) {
|
|
|
|
|
|
|
|
+ // 判断是否允许注册
|
|
|
|
+ // [系统配置] 是否允许系统用户注册
|
|
|
|
+ Boolean SYSTEM_USER_ALLOW_REGISTER = Convert.toBool(sysCommonService.getCommonByTag("SYSTEM_USER_ALLOW_REGISTER"));
|
|
|
|
+ if (!SYSTEM_USER_ALLOW_REGISTER) throw new CustException("系统已禁止注册");
|
|
|
|
+
|
|
|
|
+ // -- 参数校验 --------------------------------------------------------------
|
|
String username = sysUserDTO.getUsername();
|
|
String username = sysUserDTO.getUsername();
|
|
String password = sysUserDTO.getPassword();
|
|
String password = sysUserDTO.getPassword();
|
|
String captcha = sysUserDTO.getCaptcha();
|
|
String captcha = sysUserDTO.getCaptcha();
|
|
@@ -285,8 +288,6 @@ public class SysAuthServiceImpl implements SysAuthService {
|
|
Integer phoneAreaCode = sysUserDTO.getPhone_area_code();
|
|
Integer phoneAreaCode = sysUserDTO.getPhone_area_code();
|
|
Integer phoneValidCode = sysUserDTO.getPhone_valid_code();
|
|
Integer phoneValidCode = sysUserDTO.getPhone_valid_code();
|
|
|
|
|
|
- // -- 参数校验 --------------------------------------------------------------
|
|
|
|
-
|
|
|
|
// 判断是否处于登录错误的冻结状态 (2分钟内错误5次,则出现冻结提示)
|
|
// 判断是否处于登录错误的冻结状态 (2分钟内错误5次,则出现冻结提示)
|
|
countUtilV2.checkErrorStatus(redisKeyOfRegisterFail, username);
|
|
countUtilV2.checkErrorStatus(redisKeyOfRegisterFail, username);
|
|
countUtilV2.checkErrorStatus(redisKeyOfRegisterFail, phone);
|
|
countUtilV2.checkErrorStatus(redisKeyOfRegisterFail, phone);
|
|
@@ -297,7 +298,6 @@ public class SysAuthServiceImpl implements SysAuthService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
// [查询] 判断用户名是否存在
|
|
// [查询] 判断用户名是否存在
|
|
SysUser sysUser1 = sysUserDao.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, username));
|
|
SysUser sysUser1 = sysUserDao.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, username));
|
|
if (sysUser1 != null) throw new CustException("用户名 (" + username + ") 已被注册");
|
|
if (sysUser1 != null) throw new CustException("用户名 (" + username + ") 已被注册");
|