|
@@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 登录校验方法
|
|
* 登录校验方法
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
|
|
|
|
|
*/
|
|
*/
|
|
|
@Component
|
|
@Component
|
|
@@ -50,7 +50,7 @@ public class SysLoginService
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private RedisCache redisCache;
|
|
private RedisCache redisCache;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ISysUserService userService;
|
|
private ISysUserService userService;
|
|
|
|
|
|
|
@@ -70,7 +70,7 @@ public class SysLoginService
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 登录验证
|
|
* 登录验证
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param username 用户名
|
|
* @param username 用户名
|
|
|
* @param password 密码
|
|
* @param password 密码
|
|
|
* @param code 验证码
|
|
* @param code 验证码
|
|
@@ -115,7 +115,7 @@ public class SysLoginService
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 校验验证码
|
|
* 校验验证码
|
|
|
- *
|
|
|
|
|
|
|
+ *
|
|
|
* @param username 用户名
|
|
* @param username 用户名
|
|
|
* @param code 验证码
|
|
* @param code 验证码
|
|
|
* @param uuid 唯一标识
|
|
* @param uuid 唯一标识
|
|
@@ -141,25 +141,29 @@ public class SysLoginService
|
|
|
/**
|
|
/**
|
|
|
* 记录登录信息
|
|
* 记录登录信息
|
|
|
*/
|
|
*/
|
|
|
- public void recordLoginInfo(SysUser user)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public void recordLoginInfo(SysUser user) {
|
|
|
String ipAddr = IpUtils.getIpAddr(ServletUtils.getRequest());
|
|
String ipAddr = IpUtils.getIpAddr(ServletUtils.getRequest());
|
|
|
String loginIp = user.getLoginIp();
|
|
String loginIp = user.getLoginIp();
|
|
|
- if (com.fs.common.utils.StringUtils.isEmpty(loginIp)) {
|
|
|
|
|
- user.setLoginIp(ipAddr);
|
|
|
|
|
- } else {
|
|
|
|
|
- List<String> ipList = new ArrayList<>(Arrays.asList(loginIp.split(",")));
|
|
|
|
|
- if (!ipList.contains(ipAddr)) {
|
|
|
|
|
- ipList.add(ipAddr);
|
|
|
|
|
- user.setLoginIp(String.join(",", ipList));
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ List<String> ipList = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ if (com.fs.common.utils.StringUtils.isNotEmpty(loginIp)) {
|
|
|
|
|
+ ipList.addAll(Arrays.asList(loginIp.split(",")));
|
|
|
}
|
|
}
|
|
|
- user.setLoginIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
|
|
|
|
+ ipList.remove(ipAddr);
|
|
|
|
|
+ // 如果已满 10 个,清理第一个
|
|
|
|
|
+ if (ipList.size() >= 10) {
|
|
|
|
|
+ ipList.remove(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 新 IP 放到最后
|
|
|
|
|
+ ipList.add(ipAddr);
|
|
|
|
|
+ user.setLoginIp(String.join(",", ipList));
|
|
|
user.setLoginDate(DateUtils.getNowDate());
|
|
user.setLoginDate(DateUtils.getNowDate());
|
|
|
userService.updateUserProfile(user);
|
|
userService.updateUserProfile(user);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
public boolean checkIsNeedCheck(String username, String password, String code, String uuid)
|
|
public boolean checkIsNeedCheck(String username, String password, String code, String uuid)
|
|
|
{
|
|
{
|
|
|
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
|
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
|
|
@@ -199,12 +203,12 @@ public class SysLoginService
|
|
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
|
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
|
|
//查询当前登录用户信息
|
|
//查询当前登录用户信息
|
|
|
SysUser sysUser = userService.selectUserById(loginUser.getUserId());
|
|
SysUser sysUser = userService.selectUserById(loginUser.getUserId());
|
|
|
- Long[] userIds = new Long[]{236L, 246L, 247L, 253L,119L};
|
|
|
|
|
- for (Long userId : userIds) {
|
|
|
|
|
- if (userId.equals(sysUser.getUserId())){
|
|
|
|
|
- return false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// Long[] userIds = new Long[]{236L, 246L, 247L, 253L,119L};
|
|
|
|
|
+// for (Long userId : userIds) {
|
|
|
|
|
+// if (userId.equals(sysUser.getUserId())){
|
|
|
|
|
+// return false;
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
// 判断是否开启了扫码配置
|
|
// 判断是否开启了扫码配置
|
|
|
if (ObjectUtil.isEmpty(isNeedScan) || !isNeedScan){
|
|
if (ObjectUtil.isEmpty(isNeedScan) || !isNeedScan){
|