去除线上万能验证码功能
This commit is contained in:
@@ -22,6 +22,7 @@ import com.czg.service.account.mapper.SysMenuMapper;
|
|||||||
import com.wf.captcha.SpecCaptcha;
|
import com.wf.captcha.SpecCaptcha;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -55,6 +56,9 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|||||||
private HandoverRecordService handoverRecordService;
|
private HandoverRecordService handoverRecordService;
|
||||||
|
|
||||||
|
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String activeProfile;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getCaptcha() {
|
public Object getCaptcha() {
|
||||||
// 生成验证码(130x48,4位字符)
|
// 生成验证码(130x48,4位字符)
|
||||||
@@ -79,7 +83,21 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|||||||
@Override
|
@Override
|
||||||
public LoginVO login(SysLoginDTO loginDTO, String platType) {
|
public LoginVO login(SysLoginDTO loginDTO, String platType) {
|
||||||
Object code = redisService.get(RedisCst.LOGIN_CODE + loginDTO.uuid());
|
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("验证码错误");
|
throw new CzgException("验证码错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user