|
@@ -2,6 +2,7 @@ package com.fdkankan.ucenter.controller;
|
|
|
|
|
|
import cn.hutool.captcha.CaptchaUtil;
|
|
import cn.hutool.captcha.CaptchaUtil;
|
|
import cn.hutool.captcha.LineCaptcha;
|
|
import cn.hutool.captcha.LineCaptcha;
|
|
|
|
+import cn.hutool.captcha.generator.MathGenerator;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
import com.fdkankan.common.util.JwtUtil;
|
|
import com.fdkankan.common.util.JwtUtil;
|
|
@@ -54,7 +55,9 @@ public class LoginController extends BaseController {
|
|
if(!redisUtil.hasKey(String.format(RedisKeyUtil.loginAuthCode,id))){
|
|
if(!redisUtil.hasKey(String.format(RedisKeyUtil.loginAuthCode,id))){
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3006, LoginConstant.FAILURE_MSG_3006);
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3006, LoginConstant.FAILURE_MSG_3006);
|
|
}
|
|
}
|
|
- if(!redisUtil.get(String.format(RedisKeyUtil.loginAuthCode,id)).equals(param.getAuthCode())){
|
|
|
|
|
|
+ MathGenerator mathGenerator = new MathGenerator(3);
|
|
|
|
+ boolean verify = mathGenerator.verify(redisUtil.get(String.format(RedisKeyUtil.loginAuthCode,id)),param.getAuthCode());
|
|
|
|
+ if(!verify){
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3006, LoginConstant.FAILURE_MSG_3006);
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3006, LoginConstant.FAILURE_MSG_3006);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -107,7 +110,9 @@ public class LoginController extends BaseController {
|
|
if(!redisUtil.hasKey(String.format(RedisKeyUtil.loginAuthCode,id))){
|
|
if(!redisUtil.hasKey(String.format(RedisKeyUtil.loginAuthCode,id))){
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3006, LoginConstant.FAILURE_MSG_3006);
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3006, LoginConstant.FAILURE_MSG_3006);
|
|
}
|
|
}
|
|
- if(!redisUtil.get(String.format(RedisKeyUtil.loginAuthCode,id)).equals(param.getAuthCode())){
|
|
|
|
|
|
+ MathGenerator mathGenerator = new MathGenerator(3);
|
|
|
|
+ boolean verify = mathGenerator.verify(redisUtil.get(String.format(RedisKeyUtil.loginAuthCode,id)),param.getAuthCode());
|
|
|
|
+ if(!verify){
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3006, LoginConstant.FAILURE_MSG_3006);
|
|
throw new BusinessException(LoginConstant.FAILURE_CODE_3006, LoginConstant.FAILURE_MSG_3006);
|
|
}
|
|
}
|
|
// if(redisUtil.hasKey(String.format(RedisKeyUtil.checkUserCount,id))){
|
|
// if(redisUtil.hasKey(String.format(RedisKeyUtil.checkUserCount,id))){
|
|
@@ -218,7 +223,9 @@ public class LoginController extends BaseController {
|
|
response.setContentType("image/jpeg");
|
|
response.setContentType("image/jpeg");
|
|
String id = request.getSession().getId();
|
|
String id = request.getSession().getId();
|
|
try {
|
|
try {
|
|
- LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100,4,60);
|
|
|
|
|
|
+ LineCaptcha lineCaptcha = new LineCaptcha(400, 100);
|
|
|
|
+ MathGenerator mathGenerator = new MathGenerator(3);
|
|
|
|
+ lineCaptcha.setGenerator(mathGenerator);
|
|
redisUtil.set(String.format(RedisKeyUtil.loginAuthCode,id),lineCaptcha.getCode(),60*5);
|
|
redisUtil.set(String.format(RedisKeyUtil.loginAuthCode,id),lineCaptcha.getCode(),60*5);
|
|
lineCaptcha.write(response.getOutputStream());
|
|
lineCaptcha.write(response.getOutputStream());
|
|
response.getOutputStream().close();
|
|
response.getOutputStream().close();
|