Compare commits
No commits in common. "48f14e8a04415a386082da7a91c40a9ffb0f7ab9" and "7fc06035c7cb04bdb2a7989737b4d9797af24328" have entirely different histories.
48f14e8a04
...
7fc06035c7
@ -4,7 +4,6 @@ import enseirb.myinpulse.model.Administrator;
|
|||||||
import enseirb.myinpulse.model.Entrepreneur;
|
import enseirb.myinpulse.model.Entrepreneur;
|
||||||
import enseirb.myinpulse.service.AdminApiService;
|
import enseirb.myinpulse.service.AdminApiService;
|
||||||
import enseirb.myinpulse.service.EntrepreneurApiService;
|
import enseirb.myinpulse.service.EntrepreneurApiService;
|
||||||
import enseirb.myinpulse.service.UtilsService;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
@ -17,15 +16,15 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
public class UnauthApi {
|
public class UnauthApi {
|
||||||
|
|
||||||
private final EntrepreneurApiService entrepreneurApiService;
|
private final EntrepreneurApiService entrepreneurApiService;
|
||||||
private final UtilsService utilsService;
|
private final AdminApiService adminApiService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
UnauthApi(EntrepreneurApiService entrepreneurApiService, UtilsService utilsService) {
|
UnauthApi(EntrepreneurApiService entrepreneurApiService, AdminApiService administratorService) {
|
||||||
this.entrepreneurApiService = entrepreneurApiService;
|
this.entrepreneurApiService = entrepreneurApiService;
|
||||||
this.utilsService = utilsService;
|
this.adminApiService = administratorService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/unauth/finalize")
|
@GetMapping("/unauth/finalize")
|
||||||
public void createAccount(@AuthenticationPrincipal Jwt principal) {
|
public void createAccount(@AuthenticationPrincipal Jwt principal) {
|
||||||
boolean sneeStatus;
|
boolean sneeStatus;
|
||||||
if (principal.getClaimAsString("sneeStatus") != null) {
|
if (principal.getClaimAsString("sneeStatus") != null) {
|
||||||
@ -51,13 +50,21 @@ public class UnauthApi {
|
|||||||
course,
|
course,
|
||||||
sneeStatus,
|
sneeStatus,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
entrepreneurApiService.createAccount(e);
|
entrepreneurApiService.createAccount(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/unauth/check-if-not-pending")
|
/*
|
||||||
public Boolean checkAccountStatus(@AuthenticationPrincipal Jwt principal) {
|
* These bottom endpoints are meant for testing only
|
||||||
// Throws 404 if user not found
|
* and should not py merged to main
|
||||||
return utilsService.checkEntrepreneurNotPending(principal.getClaimAsString("email"));
|
*
|
||||||
|
*/
|
||||||
|
@GetMapping("/unauth/getAllAdmins")
|
||||||
|
public Iterable<Administrator> getEveryAdmin() {
|
||||||
|
return this.adminApiService.getAllAdmins();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/unauth/getAllEntrepreneurs")
|
||||||
|
public Iterable<Entrepreneur> getEveryEntrepreneur() {
|
||||||
|
return this.entrepreneurApiService.getAllEntrepreneurs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,10 +72,4 @@ public class UtilsService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean checkEntrepreneurNotPending(String email) {
|
|
||||||
// Throws 404 if user not found
|
|
||||||
User user = userService.getUserByEmail(email);
|
|
||||||
return !user.isPending();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -79,10 +79,6 @@ paths:
|
|||||||
$ref: "./unauthApi.yaml#/paths/~1unauth~1finalize"
|
$ref: "./unauthApi.yaml#/paths/~1unauth~1finalize"
|
||||||
/unauth/request-join/{projectId}:
|
/unauth/request-join/{projectId}:
|
||||||
$ref: "./unauthApi.yaml#/paths/~1unauth~1request-join~1{projectId}"
|
$ref: "./unauthApi.yaml#/paths/~1unauth~1request-join~1{projectId}"
|
||||||
/unauth/request-admin-role:
|
|
||||||
$ref: "./unauthApi.yaml#/paths/~1unauth~1request-admin-role"
|
|
||||||
/unauth/check-if-not-pending:
|
|
||||||
$ref: "./unauthApi.yaml#/paths/~1unauth~1check-if-not-pending"
|
|
||||||
|
|
||||||
# _ ____ __ __ ___ _ _ _ ____ ___
|
# _ ____ __ __ ___ _ _ _ ____ ___
|
||||||
# / \ | _ \| \/ |_ _| \ | | / \ | _ \_ _|
|
# / \ | _ \| \/ |_ _| \ | | / \ | _ \_ _|
|
||||||
|
@ -53,7 +53,7 @@ paths:
|
|||||||
description: Bad Token - Invalid Keycloack configuration.
|
description: Bad Token - Invalid Keycloack configuration.
|
||||||
/unauth/request-admin-role:
|
/unauth/request-admin-role:
|
||||||
post:
|
post:
|
||||||
summary: Request to become an admin
|
summary: Request to join an existing project
|
||||||
description: Submits a request for the authenticated user (keycloack authenticated) to become an admin. Their role is then changed to admin in server and Keycloak. This requires approval from a project admin.
|
description: Submits a request for the authenticated user (keycloack authenticated) to become an admin. Their role is then changed to admin in server and Keycloak. This requires approval from a project admin.
|
||||||
tags:
|
tags:
|
||||||
- Unauth API
|
- Unauth API
|
||||||
@ -66,25 +66,3 @@ paths:
|
|||||||
description: Unauthorized.
|
description: Unauthorized.
|
||||||
"403":
|
"403":
|
||||||
description: Bad Token - Invalid Keycloack configuration.
|
description: Bad Token - Invalid Keycloack configuration.
|
||||||
|
|
||||||
/unauth/check-if-not-pending:
|
|
||||||
get:
|
|
||||||
summary: Returns a boolean of whether the user's account is not pending
|
|
||||||
description: Returns a boolean with value `true` if the user's account is not pending and `false` if it is.
|
|
||||||
tags:
|
|
||||||
- Unauth API
|
|
||||||
responses:
|
|
||||||
"200":
|
|
||||||
description: Accepted - Become admin request submitted and pending approval.
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: boolean
|
|
||||||
"400":
|
|
||||||
description: Bad Request - Invalid project ID format or already member/request pending.
|
|
||||||
"401":
|
|
||||||
description: Unauthorized.
|
|
||||||
"404":
|
|
||||||
description: Bad Request - User not found in database.
|
|
||||||
"403":
|
|
||||||
description: Bad Token - Invalid Keycloack configuration.
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user