fix: whitelist mode

This commit is contained in:
tim
2025-07-15 13:02:36 +08:00
parent 1244a58872
commit 59f03f4f13
2 changed files with 7 additions and 13 deletions

View File

@@ -68,7 +68,7 @@ public class AuthController {
if (captchaEnabled && loginCaptchaEnabled && !captchaService.verify(req.getCaptcha())) {
return ResponseEntity.badRequest().body(Map.of("error", "Invalid captcha"));
}
Optional<User> userOpt = userService.findByUsername(req.getUsername());
Optional<User> userOpt = userService.findByUsername(req.getUsernameOrEmail());
if (userOpt.isEmpty() || !userService.matchesPassword(userOpt.get(), req.getPassword())) {
return ResponseEntity.badRequest().body(Map.of(
"error", "Invalid credentials",
@@ -133,7 +133,7 @@ public class AuthController {
@Data
private static class LoginRequest {
private String username;
private String usernameOrEmail;
private String password;
private String captcha;
}