added an endpoint to see if useraccuont is pending or not
This commit is contained in:
@ -2,6 +2,7 @@ package enseirb.myinpulse.controller;
|
||||
|
||||
import enseirb.myinpulse.model.Entrepreneur;
|
||||
import enseirb.myinpulse.service.EntrepreneurApiService;
|
||||
import enseirb.myinpulse.service.UtilsService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@ -14,13 +15,15 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class UnauthApi {
|
||||
|
||||
private final EntrepreneurApiService entrepreneurApiService;
|
||||
private final UtilsService utilsService;
|
||||
|
||||
@Autowired
|
||||
UnauthApi(EntrepreneurApiService entrepreneurApiService) {
|
||||
UnauthApi(EntrepreneurApiService entrepreneurApiService, UtilsService utilsService) {
|
||||
this.entrepreneurApiService = entrepreneurApiService;
|
||||
this.utilsService = utilsService;
|
||||
}
|
||||
|
||||
@GetMapping("/unauth/finalize")
|
||||
@PostMapping("/unauth/finalize")
|
||||
public void createAccount(@AuthenticationPrincipal Jwt principal) {
|
||||
boolean sneeStatus;
|
||||
if (principal.getClaimAsString("sneeStatus") != null) {
|
||||
@ -46,6 +49,13 @@ public class UnauthApi {
|
||||
course,
|
||||
sneeStatus,
|
||||
true);
|
||||
|
||||
entrepreneurApiService.createAccount(e);
|
||||
}
|
||||
|
||||
@GetMapping("/unauth/check-if-not-pending")
|
||||
public Boolean checkAccountStatus(@AuthenticationPrincipal Jwt principal) {
|
||||
// Throws 404 if user not found
|
||||
return utilsService.checkEntrepreneurNotPending(principal.getClaimAsString("email"));
|
||||
}
|
||||
}
|
||||
|
@ -72,4 +72,10 @@ public class UtilsService {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean checkEntrepreneurNotPending(String email) {
|
||||
// Throws 404 if user not found
|
||||
User user = userService.getUserByEmail(email);
|
||||
return !user.isPending();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user