lyhzzz 9 hónapja
szülő
commit
e3eb645e2b

+ 1 - 1
src/main/java/com/fdkankan/ucenter/constant/LoginConstant.java

@@ -53,7 +53,7 @@ public class LoginConstant {
     public static final String FAILURE_MSG_3014 = "账号或密码不正确";
 
     public static final int FAILURE_CODE_3015 = 3015;
-    public static final String FAILURE_MSG_3015 = "用户不存在";
+    public static final String FAILURE_MSG_3015 = "账号或密码不正确";
 
     public static final int FAILURE_CODE_3016 = 3016;
     public static final String FAILURE_MSG_3016 = "登录失败,账号无权访问";

+ 29 - 27
src/main/java/com/fdkankan/ucenter/controller/LoginController.java

@@ -105,33 +105,35 @@ public class LoginController extends BaseController {
      */
     @PostMapping("/checkUser")
     public Result checkUser(@RequestBody LoginParam param){
-        if(StringUtils.isBlank(param.getAuthCode())){
-            throw new BusinessException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
-        }
-
-        String id = request.getSession().getId();
-        String redisKey = String.format(RedisKeyUtil.loginAuthCode,id);
-        String redisCode = redisUtil.get(redisKey);
-        if(!redisUtil.hasKey(redisKey)){
-            throw new BusinessException(LoginConstant.FAILURE_CODE_3006, LoginConstant.FAILURE_MSG_3006);
-        }
-        redisUtil.del(redisKey);
-        MathGenerator mathGenerator = new MathGenerator(2);
-        boolean verify = mathGenerator.verify(redisCode,param.getAuthCode());
-        if(!verify){
-            throw new BusinessException(LoginConstant.FAILURE_CODE_3006, LoginConstant.FAILURE_MSG_3006);
-        }
-        Integer count = 0;
-        if(redisUtil.hasKey(String.format(RedisKeyUtil.checkUserCount,id))){
-            String countStr = redisUtil.get(String.format(RedisKeyUtil.checkUserCount, id));
-            count = Integer.valueOf(countStr);
-            if(count >=5){
-                throw new BusinessException(LoginConstant.FAILURE_CODE_3038, LoginConstant.FAILURE_MSG_3038);
-            }
-        }
-        count ++;
-        redisUtil.set(String.format(RedisKeyUtil.checkUserCount,id),count+"",60);
-        loginService.checkUser(param.getPhoneNum(),true);
+//        if(StringUtils.isBlank(param.getAuthCode())){
+//            throw new BusinessException(LoginConstant.FAILURE_CODE_3001, LoginConstant.FAILURE_MSG_3001);
+//        }
+//        String clientIP = ServletUtil.getClientIP(request);
+//        Integer count = 0;
+//        if(redisUtil.hasKey(String.format(RedisKeyUtil.checkUserCount,clientIP))){
+//            String countStr = redisUtil.get(String.format(RedisKeyUtil.checkUserCount, clientIP));
+//            count = Integer.valueOf(countStr);
+//            if(count >=5){
+//                throw new BusinessException(LoginConstant.FAILURE_CODE_3038, LoginConstant.FAILURE_MSG_3038);
+//            }
+//        }
+//        count ++;
+//        redisUtil.set(String.format(RedisKeyUtil.checkUserCount,clientIP),count+"",60*5);
+//
+//        String id = request.getSession().getId();
+//        String redisKey = String.format(RedisKeyUtil.loginAuthCode,id);
+//        String redisCode = redisUtil.get(redisKey);
+//        if(!redisUtil.hasKey(redisKey)){
+//            throw new BusinessException(LoginConstant.FAILURE_CODE_3006, LoginConstant.FAILURE_MSG_3006);
+//        }
+//        redisUtil.del(redisKey);
+//        MathGenerator mathGenerator = new MathGenerator(2);
+//        boolean verify = mathGenerator.verify(redisCode,param.getAuthCode());
+//        if(!verify){
+//            throw new BusinessException(LoginConstant.FAILURE_CODE_3006, LoginConstant.FAILURE_MSG_3006);
+//        }
+//
+//        loginService.checkUser(param.getPhoneNum(),true);
         return Result.success();
     }
     /**

+ 1 - 1
src/main/java/com/fdkankan/ucenter/service/impl/LoginService.java

@@ -90,7 +90,7 @@ public class LoginService {
         User user = userService.getByUserName(param.getPhoneNum());
         if(user == null){
             this.addLoginErrorNum(param.getPhoneNum());
-            throw new BusinessException(LoginConstant.FAILURE_CODE_3015, LoginConstant.FAILURE_MSG_3015);
+            throw new BusinessException(LoginConstant.FAILURE_CODE_3014, LoginConstant.FAILURE_MSG_3014);
         }
         if(!user.getPassword().equals(passwordCode)){
             this.addLoginErrorNum(param.getPhoneNum());