From da3f8c47f95972f78ca760b9328b2ff235b43e44 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Sat, 16 Mar 2024 14:22:13 +0100 Subject: [PATCH] Fix merge because i'm bad --- .../Clyde/EndPoints/CurriculumController.java | 24 ------------------- .../EndPoints/InscriptionController.java | 4 ++-- .../Clyde/EndPoints/LoginController.java | 2 +- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java index bc83924..8e9b256 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/CurriculumController.java @@ -43,28 +43,4 @@ public class CurriculumController { public ResponseEntity> findAll(){ return new ResponseEntity<>(curriculumCourseServ.findAll(),HttpStatus.OK); } - - /**@PostMapping("/curriculum") - public ResponseEntity postCurriculum(@RequestHeader("Authorization") String token,@RequestBody Curriculum curriculum){ - - if (!isSecretaryOrAdmin(token)){ - return new UnauthorizedResponse<>("you're not allowed to post a Curriculum"); - } - - CurriculumServ.save(Curriculum); - - return new ResponseEntity<>("created !",HttpStatus.CREATED); - }**/ - - - - private boolean isSecretaryOrAdmin(String authorization){ - if (authorization ==null) - return false; - - User poster = authServ.getUserFromToken(authorization); - if (poster == null) return false; - - return poster.getRole() == Role.Secretary && poster.getRole() == Role.Admin; - } } diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java index addd01b..36946b5 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java @@ -32,7 +32,7 @@ public class InscriptionController { @GetMapping("/requests/register") public ResponseEntity>> getAllRequests(@RequestHeader("Authorization") String token){ - if (!isSecretaryOrAdmin(token)){return new UnauthorizedResponse<>(null);} + if (authServ.isNotSecretaryOrAdmin(token)){return new UnauthorizedResponse<>(null);} Iterable inscriptionRequests = inscriptionServ.getAll(); ArrayList> toReturn = new ArrayList<>(); @@ -64,7 +64,7 @@ public class InscriptionController { @RequestHeader("Authorize") String token, @RequestBody RequestState requestState) { - if (!isSecretaryOrAdmin(token)) return new UnauthorizedResponse<>(null); + if (authServ.isNotSecretaryOrAdmin(token)) return new UnauthorizedResponse<>(null); inscriptionServ.modifyState(id, requestState); return null; } diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/LoginController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/LoginController.java index a47603b..1e761ec 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/LoginController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/LoginController.java @@ -49,4 +49,4 @@ public class LoginController { authServ.register(inscriptionRequest); return new ResponseEntity<>("Is OK", HttpStatus.OK); } -} \ No newline at end of file +}