liujie
2025-12-15 c79a494a58c633deb607f2e880f2ea1f6d9eea64
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
@@ -24,6 +24,7 @@
import com.ruoyi.system.service.TAppUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
@@ -59,6 +60,9 @@
    private SysPermissionService permissionService;
    @Autowired
    private TAppUserService tAppUserService;
    @Value("${spring.profiles.active}")
    private String env;
    /**
     * 登录验证
@@ -203,12 +207,20 @@
            log.info("登录用户:{} 已被删除.", username);
            throw new ServiceException(MessageUtils.message("user.password.delete"));
        }
        if ("test".equals(env) || "dev".equals(env)) {
            if (!code.equals("111111")) {
                log.info("登录用户:{} 短信验证码错误{}", username,code);
                throw new ServiceException("短信验证码错误");
            }
        } else {
        // 校验验证码
        Object cacheObject = redisCache.getCacheObject(user.getPhone());
        if(!code.equals(String.valueOf(cacheObject))){
            log.info("登录用户:{} 短信验证码错误{}", username,code);
            throw new ServiceException("短信验证码错误");
        }
        }
        AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
        LoginUserApplet loginUser = new LoginUserApplet(user.getId(), null, null, null);
        recordAppLoginInfo(loginUser.getUserId().toString());