mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-24 07:00:49 +08:00
feat: waitlist mode
This commit is contained in:
@@ -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