mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-22 06:50:53 +08:00
feat: waitlist mode
This commit is contained in:
@@ -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 部署域名
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user