whyclxw
2025-05-28 e16302f9d475c7cc4dd18c5abf1a23cb5502e362
src/main/java/com/whyc/service/LoginService.java
@@ -22,7 +22,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.*;
@Service
@@ -103,19 +102,21 @@
        return new Response<>().set(1,false,"密码错误");
    }
    public Response loginByRSA(String userName, String pwd,String deliveredCode, HttpServletRequest request) {
    public Response loginByRSA(String userName, String pwd, String deliveredCode, HttpServletRequest request, Integer validCode) {
        Response<Object> response = new Response<>();
        //默认赋值0
        response.setData3(0);
        //Locale.setDefault(Locale.ENGLISH);
        deliveredCode = deliveredCode.toUpperCase(Locale.ENGLISH);
        if(YamlProperties.fontDynamicCodeSwitch.toLowerCase(Locale.ENGLISH).equals("true")) {
            String fontDynamicCode = (String) ActionUtil.getSession().getAttribute("fontDynamicCode");
            if (fontDynamicCode == null || "".equals(fontDynamicCode)) {
                return response.set(1, false, MessageUtils.getMessage("RefreshVerification"));
            }
            if (!deliveredCode.equals(fontDynamicCode.toUpperCase(Locale.ENGLISH))) {
                return response.set(1, false, MessageUtils.getMessage("VerificationError"));
        if(validCode ==null ) { //属性不存在,则进行验证码校验;属性存在,则不进行验证码校验
            if (YamlProperties.fontDynamicCodeSwitch.toLowerCase(Locale.ENGLISH).equals("true")) {
                String fontDynamicCode = (String) ActionUtil.getSession().getAttribute("fontDynamicCode");
                if (fontDynamicCode == null || "".equals(fontDynamicCode)) {
                    return response.set(1, false, MessageUtils.getMessage("RefreshVerification"));
                }
                if (!deliveredCode.equals(fontDynamicCode.toUpperCase(Locale.ENGLISH))) {
                    return response.set(1, false, MessageUtils.getMessage("VerificationError"));
                }
            }
        }
        //验证正确,清除验证码
@@ -265,7 +266,11 @@
        }
        if (subject.isAuthenticated()) {
            //验证密码时效性
            int flag=userService.checkPasswordValidity(userInf);
            if(flag==-1){
                return response.set(1, false, "密码长期未修改已失效,请修改密码");
            }
            //登录成功
            servletContext.setAttribute(userName, request.getSession().getId());
            //日登录用户统计