|
@@ -48,7 +48,7 @@ import java.util.*;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/sys")
|
|
|
-@Api(tags = "用户登录")
|
|
|
+@Api(tags="用户登录")
|
|
|
@Slf4j
|
|
|
public class LoginController {
|
|
|
@Autowired
|
|
@@ -78,12 +78,12 @@ public class LoginController {
|
|
|
|
|
|
@ApiOperation("登录接口")
|
|
|
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
|
|
- public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel, HttpServletRequest request) {
|
|
|
+ public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel, HttpServletRequest request){
|
|
|
Result<JSONObject> result = new Result<JSONObject>();
|
|
|
String username = sysLoginModel.getUsername();
|
|
|
String password = sysLoginModel.getPassword();
|
|
|
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
|
|
- if (isLoginFailOvertimes(username)) {
|
|
|
+ if(isLoginFailOvertimes(username)){
|
|
|
return result.error500("该用户登录失败次数过多,请于10分钟后再次登录!");
|
|
|
}
|
|
|
//update-end-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
|
@@ -94,19 +94,19 @@ public class LoginController {
|
|
|
|
|
|
//update-begin-author:taoyan date:20190828 for:校验验证码
|
|
|
String captcha = sysLoginModel.getCaptcha();
|
|
|
- if (captcha == null) {
|
|
|
+ if(captcha==null){
|
|
|
result.error500("验证码无效");
|
|
|
return result;
|
|
|
}
|
|
|
String lowerCaseCaptcha = captcha.toLowerCase();
|
|
|
//update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
|
|
// 加入密钥作为混淆,避免简单的拼接,被外部利用,用户自定义该密钥即可
|
|
|
- String origin = lowerCaseCaptcha + sysLoginModel.getCheckKey() + jeecgBaseConfig.getSignatureSecret();
|
|
|
+ String origin = lowerCaseCaptcha+sysLoginModel.getCheckKey()+jeecgBaseConfig.getSignatureSecret();
|
|
|
String realKey = Md5Util.md5Encode(origin, "utf-8");
|
|
|
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
|
|
Object checkCode = redisUtil.get(realKey);
|
|
|
//当进入登录页时,有一定几率出现验证码错误 #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);
|
|
|
result.error500("验证码错误");
|
|
|
// 改成特殊的code 便于前端判断
|
|
@@ -133,11 +133,11 @@ public class LoginController {
|
|
|
//1. 校验用户是否有效
|
|
|
//update-begin-author:wangshuai date:20200601 for: 登录代码验证用户是否注销bug,if条件永远为false
|
|
|
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(SysUser::getUsername, username);
|
|
|
+ queryWrapper.eq(SysUser::getUsername,username);
|
|
|
SysUser sysUser = sysUserService.getOne(queryWrapper);
|
|
|
//update-end-author:wangshuai date:20200601 for: 登录代码验证用户是否注销bug,if条件永远为false
|
|
|
result = sysUserService.checkUserIsEffective(sysUser);
|
|
|
- if (!result.isSuccess()) {
|
|
|
+ if(!result.isSuccess()) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -160,7 +160,7 @@ public class LoginController {
|
|
|
redisUtil.del(CommonConstant.LOGIN_FAIL + username);
|
|
|
LoginUser loginUser = new LoginUser();
|
|
|
BeanUtils.copyProperties(sysUser, loginUser);
|
|
|
- baseCommonService.addLog("用户名: " + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null, loginUser);
|
|
|
+ baseCommonService.addLog("用户名: " + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null,loginUser);
|
|
|
//update-end--Author:wangshuai Date:20200714 for:登录日志没有记录人员
|
|
|
return result;
|
|
|
}
|
|
@@ -170,13 +170,13 @@ public class LoginController {
|
|
|
* 【vue3专用】获取用户信息
|
|
|
*/
|
|
|
@GetMapping("/user/getUserInfo")
|
|
|
- public Result<JSONObject> getUserInfo(HttpServletRequest request) {
|
|
|
+ public Result<JSONObject> getUserInfo(HttpServletRequest request){
|
|
|
Result<JSONObject> result = new Result<JSONObject>();
|
|
|
- String username = JwtUtil.getUserNameByToken(request);
|
|
|
- if (oConvertUtils.isNotEmpty(username)) {
|
|
|
+ String username = JwtUtil.getUserNameByToken(request);
|
|
|
+ if(oConvertUtils.isNotEmpty(username)) {
|
|
|
// 根据用户名查询用户信息
|
|
|
SysUser sysUser = sysUserService.getUserByName(username);
|
|
|
- JSONObject obj = new JSONObject();
|
|
|
+ JSONObject obj=new JSONObject();
|
|
|
|
|
|
//update-begin---author:scott ---date:2022-06-20 for:vue3前端,支持自定义首页-----------
|
|
|
String vue3Version = request.getHeader(CommonConstant.VERSION);
|
|
@@ -192,7 +192,7 @@ public class LoginController {
|
|
|
//update-begin---author:liusq ---date:2022-06-29 for:接口返回值修改,同步修改这里的判断逻辑-----------
|
|
|
//update-end---author:scott ---date::2022-06-20 for:vue3前端,支持自定义首页--------------
|
|
|
|
|
|
- obj.put("userInfo", sysUser);
|
|
|
+ obj.put("userInfo",sysUser);
|
|
|
obj.put("sysAllDictItems", sysDictService.queryAllDictItems());
|
|
|
|
|
|
result.setResult(obj);
|
|
@@ -204,25 +204,24 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 退出登录
|
|
|
- *
|
|
|
* @param request
|
|
|
* @param response
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/logout")
|
|
|
- public Result<Object> logout(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ public Result<Object> logout(HttpServletRequest request,HttpServletResponse response) {
|
|
|
//用户退出逻辑
|
|
|
String token = request.getHeader(CommonConstant.X_ACCESS_TOKEN);
|
|
|
- if (oConvertUtils.isEmpty(token)) {
|
|
|
+ if(oConvertUtils.isEmpty(token)) {
|
|
|
return Result.error("退出登录失败!");
|
|
|
}
|
|
|
String username = JwtUtil.getUsername(token);
|
|
|
LoginUser sysUser = sysBaseApi.getUserByName(username);
|
|
|
- if (sysUser != null) {
|
|
|
+ if(sysUser!=null) {
|
|
|
//update-begin--Author:wangshuai Date:20200714 for:登出日志没有记录人员
|
|
|
- baseCommonService.addLog("用户名: " + sysUser.getRealname() + ",退出成功!", CommonConstant.LOG_TYPE_1, null, sysUser);
|
|
|
+ baseCommonService.addLog("用户名: "+sysUser.getRealname()+",退出成功!", CommonConstant.LOG_TYPE_1, null,sysUser);
|
|
|
//update-end--Author:wangshuai Date:20200714 for:登出日志没有记录人员
|
|
|
- log.info(" 用户名: " + sysUser.getRealname() + ",退出成功! ");
|
|
|
+ log.info(" 用户名: "+sysUser.getRealname()+",退出成功! ");
|
|
|
//清空用户登录Token缓存
|
|
|
redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token);
|
|
|
//清空用户登录Shiro权限缓存
|
|
@@ -232,14 +231,13 @@ public class LoginController {
|
|
|
//调用shiro的logout
|
|
|
SecurityUtils.getSubject().logout();
|
|
|
return Result.ok("退出登录成功!");
|
|
|
- } else {
|
|
|
+ }else {
|
|
|
return Result.error("Token无效!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取访问量
|
|
|
- *
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("loginfo")
|
|
@@ -259,9 +257,9 @@ public class LoginController {
|
|
|
// 获取系统访问记录
|
|
|
Long totalVisitCount = logService.findTotalVisitCount();
|
|
|
obj.put("totalVisitCount", totalVisitCount);
|
|
|
- Long todayVisitCount = logService.findTodayVisitCount(dayStart, dayEnd);
|
|
|
+ Long todayVisitCount = logService.findTodayVisitCount(dayStart,dayEnd);
|
|
|
obj.put("todayVisitCount", todayVisitCount);
|
|
|
- Long todayIp = logService.findTodayIp(dayStart, dayEnd);
|
|
|
+ Long todayIp = logService.findTodayIp(dayStart,dayEnd);
|
|
|
//update-end--Author:zhangweijian Date:20190428 for:传入开始时间,结束时间参数
|
|
|
obj.put("todayIp", todayIp);
|
|
|
result.setResult(obj);
|
|
@@ -271,22 +269,21 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 获取访问量
|
|
|
- *
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("visitInfo")
|
|
|
- public Result<List<Map<String, Object>>> visitInfo() {
|
|
|
- Result<List<Map<String, Object>>> result = new Result<List<Map<String, Object>>>();
|
|
|
+ public Result<List<Map<String,Object>>> visitInfo() {
|
|
|
+ Result<List<Map<String,Object>>> result = new Result<List<Map<String,Object>>>();
|
|
|
Calendar calendar = new GregorianCalendar();
|
|
|
- calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
- calendar.set(Calendar.MINUTE, 0);
|
|
|
- calendar.set(Calendar.SECOND, 0);
|
|
|
- calendar.set(Calendar.MILLISECOND, 0);
|
|
|
+ calendar.set(Calendar.HOUR_OF_DAY,0);
|
|
|
+ calendar.set(Calendar.MINUTE,0);
|
|
|
+ calendar.set(Calendar.SECOND,0);
|
|
|
+ calendar.set(Calendar.MILLISECOND,0);
|
|
|
calendar.add(Calendar.DAY_OF_MONTH, 1);
|
|
|
Date dayEnd = calendar.getTime();
|
|
|
calendar.add(Calendar.DAY_OF_MONTH, -7);
|
|
|
Date dayStart = calendar.getTime();
|
|
|
- List<Map<String, Object>> list = logService.findVisitCount(dayStart, dayEnd);
|
|
|
+ List<Map<String,Object>> list = logService.findVisitCount(dayStart, dayEnd);
|
|
|
result.setResult(oConvertUtils.toLowerCasePageList(list));
|
|
|
return result;
|
|
|
}
|
|
@@ -294,19 +291,27 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 登陆成功选择用户当前部门
|
|
|
- *
|
|
|
* @param user
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/selectDepart", method = RequestMethod.PUT)
|
|
|
public Result<JSONObject> selectDepart(@RequestBody SysUser user) {
|
|
|
- Result<JSONObject> result = new Result<>();
|
|
|
+ Result<JSONObject> result = new Result<JSONObject>();
|
|
|
String username = user.getUsername();
|
|
|
- if (oConvertUtils.isEmpty(username)) {
|
|
|
- LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ if(oConvertUtils.isEmpty(username)) {
|
|
|
+ LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
|
|
|
username = sysUser.getUsername();
|
|
|
}
|
|
|
- JSONObject obj = sysUserService.updateSelectDept(user, username);
|
|
|
+
|
|
|
+ //获取登录部门
|
|
|
+ String orgCode= user.getOrgCode();
|
|
|
+ //获取登录租户
|
|
|
+ Integer tenantId = user.getLoginTenantId();
|
|
|
+ //设置用户登录部门和登录租户
|
|
|
+ this.sysUserService.updateUserDepart(username, orgCode,tenantId);
|
|
|
+ SysUser sysUser = sysUserService.getUserByName(username);
|
|
|
+ JSONObject obj = new JSONObject();
|
|
|
+ obj.put("userInfo", sysUser);
|
|
|
result.setResult(obj);
|
|
|
return result;
|
|
|
}
|
|
@@ -322,16 +327,16 @@ public class LoginController {
|
|
|
Result<String> result = new Result<String>();
|
|
|
String mobile = jsonObject.get("mobile").toString();
|
|
|
//手机号模式 登录模式: "2" 注册模式: "1"
|
|
|
- String smsmode = jsonObject.get("smsmode").toString();
|
|
|
+ String smsmode=jsonObject.get("smsmode").toString();
|
|
|
log.info(mobile);
|
|
|
- if (oConvertUtils.isEmpty(mobile)) {
|
|
|
+ if(oConvertUtils.isEmpty(mobile)){
|
|
|
result.setMessage("手机号不允许为空!");
|
|
|
result.setSuccess(false);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
|
|
- String redisKey = CommonConstant.PHONE_REDIS_KEY_PRE + mobile;
|
|
|
+ String redisKey = CommonConstant.PHONE_REDIS_KEY_PRE+mobile;
|
|
|
Object object = redisUtil.get(redisKey);
|
|
|
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
|
|
|
|
@@ -350,20 +355,20 @@ public class LoginController {
|
|
|
//注册模板
|
|
|
if (CommonConstant.SMS_TPL_TYPE_1.equals(smsmode)) {
|
|
|
SysUser sysUser = sysUserService.getUserByPhone(mobile);
|
|
|
- if (sysUser != null) {
|
|
|
+ if(sysUser!=null) {
|
|
|
result.error500(" 手机号已经注册,请直接登录!");
|
|
|
baseCommonService.addLog("手机号已经注册,请直接登录!", CommonConstant.LOG_TYPE_1, null);
|
|
|
return result;
|
|
|
}
|
|
|
b = DySmsHelper.sendSms(mobile, obj, DySmsEnum.REGISTER_TEMPLATE_CODE);
|
|
|
- } else {
|
|
|
+ }else {
|
|
|
//登录模式,校验用户有效性
|
|
|
SysUser sysUser = sysUserService.getUserByPhone(mobile);
|
|
|
result = sysUserService.checkUserIsEffective(sysUser);
|
|
|
- if (!result.isSuccess()) {
|
|
|
+ if(!result.isSuccess()) {
|
|
|
String message = result.getMessage();
|
|
|
- String userNotExist = "该用户不存在,请注册";
|
|
|
- if (userNotExist.equals(message)) {
|
|
|
+ String userNotExist="该用户不存在,请注册";
|
|
|
+ if(userNotExist.equals(message)){
|
|
|
result.error500("该用户不存在或未绑定手机号");
|
|
|
}
|
|
|
return result;
|
|
@@ -375,7 +380,7 @@ public class LoginController {
|
|
|
if (CommonConstant.SMS_TPL_TYPE_0.equals(smsmode)) {
|
|
|
//登录模板
|
|
|
b = DySmsHelper.sendSms(mobile, obj, DySmsEnum.LOGIN_TEMPLATE_CODE);
|
|
|
- } else if (CommonConstant.SMS_TPL_TYPE_2.equals(smsmode)) {
|
|
|
+ } else if(CommonConstant.SMS_TPL_TYPE_2.equals(smsmode)) {
|
|
|
//忘记密码模板
|
|
|
b = DySmsHelper.sendSms(mobile, obj, DySmsEnum.FORGET_PASSWORD_TEMPLATE_CODE);
|
|
|
}
|
|
@@ -418,21 +423,21 @@ public class LoginController {
|
|
|
Result<JSONObject> result = new Result<JSONObject>();
|
|
|
String phone = jsonObject.getString("mobile");
|
|
|
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
|
|
- if (isLoginFailOvertimes(phone)) {
|
|
|
+ if(isLoginFailOvertimes(phone)){
|
|
|
return result.error500("该用户登录失败次数过多,请于10分钟后再次登录!");
|
|
|
}
|
|
|
//update-end-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
|
|
//校验用户有效性
|
|
|
SysUser sysUser = sysUserService.getUserByPhone(phone);
|
|
|
result = sysUserService.checkUserIsEffective(sysUser);
|
|
|
- if (!result.isSuccess()) {
|
|
|
+ if(!result.isSuccess()) {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
String smscode = jsonObject.getString("captcha");
|
|
|
|
|
|
//update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
|
|
- String redisKey = CommonConstant.PHONE_REDIS_KEY_PRE + phone;
|
|
|
+ String redisKey = CommonConstant.PHONE_REDIS_KEY_PRE+phone;
|
|
|
Object code = redisUtil.get(redisKey);
|
|
|
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
|
|
|
|
@@ -473,7 +478,7 @@ public class LoginController {
|
|
|
obj.put("token", token);
|
|
|
|
|
|
//2.设置登录租户
|
|
|
- Result<JSONObject> loginTenantError = sysUserService.setLoginTenant(sysUser, obj, username, result);
|
|
|
+ Result<JSONObject> loginTenantError = sysUserService.setLoginTenant(sysUser, obj, username,result);
|
|
|
if (loginTenantError != null) {
|
|
|
return loginTenantError;
|
|
|
}
|
|
@@ -487,14 +492,14 @@ public class LoginController {
|
|
|
if (departs == null || departs.size() == 0) {
|
|
|
obj.put("multi_depart", 0);
|
|
|
} else if (departs.size() == 1) {
|
|
|
- sysUserService.updateUserDepart(username, departs.get(0).getOrgCode(), null);
|
|
|
+ sysUserService.updateUserDepart(username, departs.get(0).getOrgCode(),null);
|
|
|
obj.put("multi_depart", 1);
|
|
|
} else {
|
|
|
//查询当前是否有登录部门
|
|
|
// update-begin--Author:wangshuai Date:20200805 for:如果用戶为选择部门,数据库为存在上一次登录部门,则取一条存进去
|
|
|
SysUser sysUserById = sysUserService.getById(sysUser.getId());
|
|
|
- if (oConvertUtils.isEmpty(sysUserById.getOrgCode())) {
|
|
|
- sysUserService.updateUserDepart(username, departs.get(0).getOrgCode(), null);
|
|
|
+ if(oConvertUtils.isEmpty(sysUserById.getOrgCode())){
|
|
|
+ sysUserService.updateUserDepart(username, departs.get(0).getOrgCode(),null);
|
|
|
}
|
|
|
// update-end--Author:wangshuai Date:20200805 for:如果用戶为选择部门,数据库为存在上一次登录部门,则取一条存进去
|
|
|
obj.put("multi_depart", 2);
|
|
@@ -503,7 +508,7 @@ public class LoginController {
|
|
|
//update-begin---author:scott ---date:2024-01-05 for:【QQYUN-7802】前端在登录时加载了两次数据字典,建议优化下,避免数据字典太多时可能产生的性能问题 #956---
|
|
|
// login接口,在vue3前端下不加载字典数据,vue2下加载字典
|
|
|
String vue3Version = request.getHeader(CommonConstant.VERSION);
|
|
|
- if (oConvertUtils.isEmpty(vue3Version)) {
|
|
|
+ if(oConvertUtils.isEmpty(vue3Version)){
|
|
|
obj.put("sysAllDictItems", sysDictService.queryAllDictItems());
|
|
|
}
|
|
|
//end-begin---author:scott ---date:2024-01-05 for:【QQYUN-7802】前端在登录时加载了两次数据字典,建议优化下,避免数据字典太多时可能产生的性能问题 #956---
|
|
@@ -515,38 +520,36 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 获取加密字符串
|
|
|
- *
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping(value = "/getEncryptedString")
|
|
|
- public Result<Map<String, String>> getEncryptedString() {
|
|
|
- Result<Map<String, String>> result = new Result<Map<String, String>>();
|
|
|
- Map<String, String> map = new HashMap(5);
|
|
|
+ public Result<Map<String,String>> getEncryptedString(){
|
|
|
+ Result<Map<String,String>> result = new Result<Map<String,String>>();
|
|
|
+ Map<String,String> map = new HashMap(5);
|
|
|
map.put("key", EncryptedString.key);
|
|
|
- map.put("iv", EncryptedString.iv);
|
|
|
+ map.put("iv",EncryptedString.iv);
|
|
|
result.setResult(map);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 后台生成图形验证码 :有效
|
|
|
- *
|
|
|
* @param response
|
|
|
* @param key
|
|
|
*/
|
|
|
@ApiOperation("获取验证码")
|
|
|
@GetMapping(value = "/randomImage/{key}")
|
|
|
- public Result<String> randomImage(HttpServletResponse response, @PathVariable("key") String key) {
|
|
|
+ public Result<String> randomImage(HttpServletResponse response,@PathVariable("key") String key){
|
|
|
Result<String> res = new Result<String>();
|
|
|
try {
|
|
|
//生成验证码
|
|
|
- String code = RandomUtil.randomString(BASE_CHECK_CODES, 4);
|
|
|
+ String code = RandomUtil.randomString(BASE_CHECK_CODES,4);
|
|
|
//存到redis中
|
|
|
String lowerCaseCode = code.toLowerCase();
|
|
|
|
|
|
//update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
|
|
// 加入密钥作为混淆,避免简单的拼接,被外部利用,用户自定义该密钥即可
|
|
|
- String origin = lowerCaseCode + key + jeecgBaseConfig.getSignatureSecret();
|
|
|
+ String origin = lowerCaseCode+key+jeecgBaseConfig.getSignatureSecret();
|
|
|
String realKey = Md5Util.md5Encode(origin, "utf-8");
|
|
|
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
|
|
|
|
@@ -577,33 +580,31 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 图形验证码
|
|
|
- *
|
|
|
* @param sysLoginModel
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping(value = "/checkCaptcha", method = RequestMethod.POST)
|
|
|
- public Result<?> checkCaptcha(@RequestBody SysLoginModel sysLoginModel) {
|
|
|
+ public Result<?> checkCaptcha(@RequestBody SysLoginModel sysLoginModel){
|
|
|
String captcha = sysLoginModel.getCaptcha();
|
|
|
String checkKey = sysLoginModel.getCheckKey();
|
|
|
- if (captcha == null) {
|
|
|
+ if(captcha==null){
|
|
|
return Result.error("验证码无效");
|
|
|
}
|
|
|
String lowerCaseCaptcha = captcha.toLowerCase();
|
|
|
- String realKey = Md5Util.md5Encode(lowerCaseCaptcha + checkKey, "utf-8");
|
|
|
+ String realKey = Md5Util.md5Encode(lowerCaseCaptcha+checkKey, "utf-8");
|
|
|
Object checkCode = redisUtil.get(realKey);
|
|
|
- if (checkCode == null || !checkCode.equals(lowerCaseCaptcha)) {
|
|
|
+ if(checkCode==null || !checkCode.equals(lowerCaseCaptcha)) {
|
|
|
return Result.error("验证码错误");
|
|
|
}
|
|
|
return Result.ok();
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 登录二维码
|
|
|
*/
|
|
|
@ApiOperation(value = "登录二维码", notes = "登录二维码")
|
|
|
@GetMapping("/getLoginQrcode")
|
|
|
- public Result<?> getLoginQrcode() {
|
|
|
- String qrcodeId = CommonConstant.LOGIN_QRCODE_PRE + IdWorker.getIdStr();
|
|
|
+ public Result<?> getLoginQrcode() {
|
|
|
+ String qrcodeId = CommonConstant.LOGIN_QRCODE_PRE+IdWorker.getIdStr();
|
|
|
//定义二维码参数
|
|
|
Map params = new HashMap(5);
|
|
|
params.put("qrcodeId", qrcodeId);
|
|
@@ -611,7 +612,6 @@ public class LoginController {
|
|
|
redisUtil.set(CommonConstant.LOGIN_QRCODE + qrcodeId, qrcodeId, 30);
|
|
|
return Result.OK(params);
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 扫码二维码
|
|
|
*/
|
|
@@ -621,7 +621,7 @@ public class LoginController {
|
|
|
Object check = redisUtil.get(CommonConstant.LOGIN_QRCODE + qrcodeId);
|
|
|
if (oConvertUtils.isNotEmpty(check)) {
|
|
|
//存放token给前台读取
|
|
|
- redisUtil.set(CommonConstant.LOGIN_QRCODE_TOKEN + qrcodeId, token, 60);
|
|
|
+ redisUtil.set(CommonConstant.LOGIN_QRCODE_TOKEN+qrcodeId, token, 60);
|
|
|
} else {
|
|
|
return Result.error("二维码已过期,请刷新后重试");
|
|
|
}
|
|
@@ -654,16 +654,15 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 登录失败超出次数5 返回true
|
|
|
- *
|
|
|
* @param username
|
|
|
* @return
|
|
|
*/
|
|
|
- private boolean isLoginFailOvertimes(String username) {
|
|
|
+ private boolean isLoginFailOvertimes(String username){
|
|
|
String key = CommonConstant.LOGIN_FAIL + username;
|
|
|
Object failTime = redisUtil.get(key);
|
|
|
- if (failTime != null) {
|
|
|
+ if(failTime!=null){
|
|
|
Integer val = Integer.parseInt(failTime.toString());
|
|
|
- if (val > 5) {
|
|
|
+ if(val>5){
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
@@ -672,14 +671,13 @@ public class LoginController {
|
|
|
|
|
|
/**
|
|
|
* 记录登录失败次数
|
|
|
- *
|
|
|
* @param username
|
|
|
*/
|
|
|
- private void addLoginFailOvertimes(String username) {
|
|
|
+ private void addLoginFailOvertimes(String username){
|
|
|
String key = CommonConstant.LOGIN_FAIL + username;
|
|
|
Object failTime = redisUtil.get(key);
|
|
|
Integer val = 0;
|
|
|
- if (failTime != null) {
|
|
|
+ if(failTime!=null){
|
|
|
val = Integer.parseInt(failTime.toString());
|
|
|
}
|
|
|
// 10分钟
|