Merge branch 'backend-test' into front_foundation
Some checks failed
Format / formatting (push) Failing after 6s
Build / build (push) Successful in 41s
CI / build (push) Failing after 10s

This commit is contained in:
Mohamed Maoulainine Maoulainine
2025-05-09 22:59:23 +02:00
4 changed files with 44 additions and 19 deletions

View File

@ -4,6 +4,7 @@ import enseirb.myinpulse.model.Administrator;
import enseirb.myinpulse.model.Entrepreneur;
import enseirb.myinpulse.service.AdminApiService;
import enseirb.myinpulse.service.EntrepreneurApiService;
import enseirb.myinpulse.service.UtilsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -16,15 +17,15 @@ import org.springframework.web.bind.annotation.*;
public class UnauthApi {
private final EntrepreneurApiService entrepreneurApiService;
private final AdminApiService adminApiService;
private final UtilsService utilsService;
@Autowired
UnauthApi(EntrepreneurApiService entrepreneurApiService, AdminApiService administratorService) {
UnauthApi(EntrepreneurApiService entrepreneurApiService, UtilsService utilsService) {
this.entrepreneurApiService = entrepreneurApiService;
this.adminApiService = administratorService;
this.utilsService = utilsService;
}
@GetMapping("/unauth/finalize")
@PostMapping("/unauth/finalize")
public void createAccount(@AuthenticationPrincipal Jwt principal) {
boolean sneeStatus;
if (principal.getClaimAsString("sneeStatus") != null) {
@ -50,21 +51,13 @@ public class UnauthApi {
course,
sneeStatus,
true);
entrepreneurApiService.createAccount(e);
}
/*
* These bottom endpoints are meant for testing only
* and should not py merged to main
*
*/
@GetMapping("/unauth/getAllAdmins")
public Iterable<Administrator> getEveryAdmin() {
return this.adminApiService.getAllAdmins();
}
@GetMapping("/unauth/getAllEntrepreneurs")
public Iterable<Entrepreneur> getEveryEntrepreneur() {
return this.entrepreneurApiService.getAllEntrepreneurs();
@GetMapping("/unauth/check-if-not-pending")
public Boolean checkAccountStatus(@AuthenticationPrincipal Jwt principal) {
// Throws 404 if user not found
return utilsService.checkEntrepreneurNotPending(principal.getClaimAsString("email"));
}
}

View File

@ -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();
}
}