feat: waitlist mode

This commit is contained in:
tim
2025-07-15 11:41:24 +08:00
parent 72236ad290
commit 5b886420c5
5 changed files with 30 additions and 8 deletions

View File

@@ -71,6 +71,7 @@ public class SecurityConfig {
CorsConfiguration cfg = new CorsConfiguration();
cfg.setAllowedOrigins(List.of(
"http://127.0.0.1:8080", // 前端调试地址
"http://localhost:8080", // 前端调试地址
// "http://129.204.254.110", // 前端调试地址
"https://www.open-isle.com", // 生产域名
"689d7858-openisle.cjt807916.workers.dev" // cloudflare 部署域名

View File

@@ -97,11 +97,24 @@ public class AuthController {
Optional<User> user = googleAuthService.authenticate(req.getIdToken(), req.getReason(), registerModeService.getRegisterMode());
if (user.isPresent()) {
if (!user.get().isApproved()) {
return ResponseEntity.badRequest().body(Map.of("error", "Account awaiting approval"));
if (req.getReason() != null && !req.getReason().isEmpty()) {
// do not send empty notifition (while try login)
for (User admin : userRepository.findByRole(com.openisle.model.Role.ADMIN)) {
notificationService.createNotification(admin, NotificationType.REGISTER_REQUEST, null, null,
null, user.get(), null, req.getReason());
}
}
return ResponseEntity.badRequest().body(Map.of(
"error", "Account awaiting approval",
"reason_code", "NOT_APPROVED"
));
}
return ResponseEntity.ok(Map.of("token", jwtService.generateToken(user.get().getUsername())));
}
return ResponseEntity.badRequest().body(Map.of("error", "Invalid google token"));
return ResponseEntity.badRequest().body(Map.of(
"error", "Invalid google token",
"reason_code", "INVALID_CREDENTIALS"
));
}
@GetMapping("/check")