Compare commits
2 Commits
8257edba57
...
c2a73d4f4d
Author | SHA1 | Date |
---|---|---|
|
c2a73d4f4d | |
|
5dad69008e |
|
@ -23,7 +23,6 @@ import org.jeecg.config.JeecgBaseConfig;
|
||||||
import org.jeecg.modules.base.service.BaseCommonService;
|
import org.jeecg.modules.base.service.BaseCommonService;
|
||||||
import org.jeecg.modules.system.entity.SysDepart;
|
import org.jeecg.modules.system.entity.SysDepart;
|
||||||
import org.jeecg.modules.system.entity.SysRoleIndex;
|
import org.jeecg.modules.system.entity.SysRoleIndex;
|
||||||
import org.jeecg.modules.system.entity.SysTenant;
|
|
||||||
import org.jeecg.modules.system.entity.SysUser;
|
import org.jeecg.modules.system.entity.SysUser;
|
||||||
import org.jeecg.modules.system.model.SysLoginModel;
|
import org.jeecg.modules.system.model.SysLoginModel;
|
||||||
import org.jeecg.modules.system.service.*;
|
import org.jeecg.modules.system.service.*;
|
||||||
|
@ -31,14 +30,12 @@ import org.jeecg.modules.system.service.impl.SysBaseApiImpl;
|
||||||
import org.jeecg.modules.system.util.RandImageUtil;
|
import org.jeecg.modules.system.util.RandImageUtil;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author scott
|
* @Author scott
|
||||||
|
@ -81,24 +78,24 @@ public class LoginController {
|
||||||
}
|
}
|
||||||
|
|
||||||
// step.1 验证码check
|
// step.1 验证码check
|
||||||
String captcha = sysLoginModel.getCaptcha();
|
// String captcha = sysLoginModel.getCaptcha();
|
||||||
if(captcha==null){
|
// if(captcha==null){
|
||||||
result.error500("验证码无效");
|
// result.error500("验证码无效");
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
String lowerCaseCaptcha = captcha.toLowerCase();
|
// String lowerCaseCaptcha = captcha.toLowerCase();
|
||||||
// 加入密钥作为混淆,避免简单的拼接,被外部利用,用户自定义该密钥即可
|
// // 加入密钥作为混淆,避免简单的拼接,被外部利用,用户自定义该密钥即可
|
||||||
String origin = lowerCaseCaptcha+sysLoginModel.getCheckKey()+jeecgBaseConfig.getSignatureSecret();
|
// String origin = lowerCaseCaptcha+sysLoginModel.getCheckKey()+jeecgBaseConfig.getSignatureSecret();
|
||||||
String realKey = Md5Util.md5Encode(origin, "utf-8");
|
// String realKey = Md5Util.md5Encode(origin, "utf-8");
|
||||||
Object checkCode = redisUtil.get(realKey);
|
// Object checkCode = redisUtil.get(realKey);
|
||||||
//当进入登录页时,有一定几率出现验证码错误 #1714
|
// //当进入登录页时,有一定几率出现验证码错误 #1714
|
||||||
if(checkCode==null || !checkCode.toString().equals(lowerCaseCaptcha)) {
|
// if(checkCode==null || !checkCode.toString().equals(lowerCaseCaptcha)) {
|
||||||
log.warn("验证码错误,key= {} , Ui checkCode= {}, Redis checkCode = {}", sysLoginModel.getCheckKey(), lowerCaseCaptcha, checkCode);
|
// log.warn("验证码错误,key= {} , Ui checkCode= {}, Redis checkCode = {}", sysLoginModel.getCheckKey(), lowerCaseCaptcha, checkCode);
|
||||||
result.error500("验证码错误");
|
// result.error500("验证码错误");
|
||||||
// 改成特殊的code 便于前端判断
|
// // 改成特殊的code 便于前端判断
|
||||||
result.setCode(HttpStatus.PRECONDITION_FAILED.value());
|
// result.setCode(HttpStatus.PRECONDITION_FAILED.value());
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// step.2 校验用户是否存在且有效
|
// step.2 校验用户是否存在且有效
|
||||||
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
@ -122,7 +119,7 @@ public class LoginController {
|
||||||
userInfo(sysUser, result, request);
|
userInfo(sysUser, result, request);
|
||||||
|
|
||||||
// step.5 登录成功删除验证码
|
// step.5 登录成功删除验证码
|
||||||
redisUtil.del(realKey);
|
// redisUtil.del(realKey);
|
||||||
redisUtil.del(CommonConstant.LOGIN_FAIL + username);
|
redisUtil.del(CommonConstant.LOGIN_FAIL + username);
|
||||||
|
|
||||||
// step.6 记录用户登录日志
|
// step.6 记录用户登录日志
|
||||||
|
|
Loading…
Reference in New Issue