|
|
@@ -12,6 +12,7 @@ import com.etotem.cfc.service.UserService;
|
|
|
import com.etotem.cfc.service.VerificationCodeService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import javax.annotation.Resource;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
@@ -41,6 +42,9 @@ public class AdminAuthController {
|
|
|
@Resource
|
|
|
private LoginAttemptService loginAttemptService;
|
|
|
|
|
|
+ @Value("${admin.skip-captcha:false}")
|
|
|
+ private boolean skipCaptcha;
|
|
|
+
|
|
|
/**
|
|
|
* 发送管理员登录验证码
|
|
|
*/
|
|
|
@@ -95,10 +99,13 @@ public class AdminAuthController {
|
|
|
return Result.error("登录尝试过多,请" + (remaining / 60000 + 1) + "分钟后重试");
|
|
|
}
|
|
|
|
|
|
- boolean valid = verificationCodeService.verifyCode(dto.getPhone(), dto.getCode(), "admin_login");
|
|
|
- if (!valid) {
|
|
|
- loginAttemptService.recordFailure(lockKey);
|
|
|
- return Result.error("验证码错误或已过期");
|
|
|
+ // 测试环境可跳过验证码验证(配置 admin.skip-captcha: true)
|
|
|
+ if (!skipCaptcha) {
|
|
|
+ boolean valid = verificationCodeService.verifyCode(dto.getPhone(), dto.getCode(), "admin_login");
|
|
|
+ if (!valid) {
|
|
|
+ loginAttemptService.recordFailure(lockKey);
|
|
|
+ return Result.error("验证码错误或已过期");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
|