去除线上万能验证码功能

This commit is contained in:
gong
2025-12-08 15:42:46 +08:00
parent 2513d137c3
commit 0673cc5a24

View File

@@ -22,6 +22,7 @@ import com.czg.service.account.mapper.SysMenuMapper;
import com.wf.captcha.SpecCaptcha;
import jakarta.annotation.Resource;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@@ -55,6 +56,9 @@ public class AuthorizationServiceImpl implements AuthorizationService {
private HandoverRecordService handoverRecordService;
@Value("${spring.profiles.active}")
private String activeProfile;
@Override
public Object getCaptcha() {
// 生成验证码130x484位字符
@@ -79,7 +83,21 @@ public class AuthorizationServiceImpl implements AuthorizationService {
@Override
public LoginVO login(SysLoginDTO loginDTO, String platType) {
Object code = redisService.get(RedisCst.LOGIN_CODE + loginDTO.uuid());
if (!"666666".equals(loginDTO.code()) && (code == null || !code.equals(loginDTO.code().toLowerCase()))) {
if (code == null) {
throw new CzgException("验证码已过期");
}
String userCode = loginDTO.code();
boolean isDevEnv = "dev".equals(activeProfile);
// 核心验证逻辑
boolean isCodeValid =
// 开发环境万能码
(isDevEnv && "666666".equals(userCode))
// 正常验证码匹配
|| code.equals(userCode.toLowerCase());
if (!isCodeValid) {
throw new CzgException("验证码错误");
}