YYC
2025-04-23 0977e1ea1e081c70952443530eb20f82fadb6cf4
src/main/java/com/fzzy/web/LoginController.java
@@ -1,5 +1,6 @@
package com.fzzy.web;
import com.fzzy.sys.LogLoginService;
import com.fzzy.sys.UserPR;
import com.fzzy.sys.entity.SysUser;
import com.wf.captcha.ArithmeticCaptcha;
@@ -26,6 +27,8 @@
    @Autowired
    private UserPR userPR;
    @Autowired
    private LogLoginService logLoginService;
    /**
     * 登录验证入口
@@ -54,16 +57,32 @@
            return "redirect:/login?tag=04&username=" + username;
        }
        //判断限制登陆
        int num = logLoginService.checkLoginLimit(request, username);
        if (num >= 3) {
            return "redirect:/login?tag=11&username=" + username;
        }
        SysUser user = userPR.listById(username);
        if (null == user) {
            num = logLoginService.addNoUser(request, username);
            if (num >= 3) {
                return "redirect:/login?tag=12&username=" + username;
            }
            return "redirect:/login?tag=05&username=" + username;
        }
        boolean tag = userPR.checkPassword(password, user);
        if (!tag){
            num = logLoginService.addPwdError(request, user);
            if (num >= 3) {
                return "redirect:/login?tag=11&username=" + username;
            }
            return "redirect:/login?tag=06&username=" + username;
        }
        request.getSession().setAttribute("user", user);
        //增加登录日志
        logLoginService.addLoginInfo(request, user);
        return "redirect:/home";
    }
@@ -103,6 +122,12 @@
            if ("10".equals(tag)) {
                tag = "您的账号在其他地方登录,被迫下线";
            }
            if ("11".equals(tag)) {
                tag = "连续3次错误,限制登陆60分钟";
            }
            if ("12".equals(tag)) {
                tag = "连续3次输入不存在账号,限制登陆60分钟";
            }
            view.addObject("TAG", tag);
            view.addObject("USERNAME", username);
        }