From 1f14890d435bc8bd3d0350616708dab09f777e4f Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Fri, 15 Mar 2024 18:54:53 +0100 Subject: [PATCH 1/7] added ApplicationController and Application enum --- .../EndPoints/ApplicationsController.java | 62 +++++++++++++++++++ .../herisson/Clyde/Tables/Applications.java | 24 +++++++ 2 files changed, 86 insertions(+) create mode 100644 backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java create mode 100644 backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java new file mode 100644 index 0000000..d044bf7 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java @@ -0,0 +1,62 @@ +package ovh.herisson.Clyde.EndPoints; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RestController; +import ovh.herisson.Clyde.Services.AuthenticatorService; +import ovh.herisson.Clyde.Tables.Applications; +import ovh.herisson.Clyde.Tables.Role; + +import java.util.ArrayList; + +@RestController +public class ApplicationsController { + + AuthenticatorService authServ; + + public ApplicationsController(AuthenticatorService authServ){ + this.authServ = authServ; + } + + + /** return a list of authorized applications. + * depends on the token + */ + @GetMapping("/apps") + public ResponseEntity> getAuthorizedApps(@RequestHeader("Authorization") String token){ + + return new ResponseEntity<>(getAuthorizedApplications(token), HttpStatus.OK); + } + + @GetMapping("/apps/{identifier}") + public ResponseEntity getAppAuthorization(@PathVariable Applications identifier, @RequestHeader("Authorization") String token){ + + if (getAuthorizedApplications(token).contains(identifier)){ + return new ResponseEntity<>(true, HttpStatus.OK); + } + return new ResponseEntity<>(false, HttpStatus.OK); + } + + public ArrayList getAuthorizedApplications(String token){ + Role posterRole = authServ.getUserFromToken(token).getRole(); + ArrayList authorizedApps = new ArrayList<>(); + + authorizedApps.add(Applications.LOGIN); + authorizedApps.add(Applications.PROFILE); + authorizedApps.add(Applications.MSG); + authorizedApps.add(Applications.FORUM); + authorizedApps.add(Applications.RDV); + + if (posterRole == Role.Student || posterRole == Role.Admin) return authorizedApps; + + if (posterRole == Role.Teacher || posterRole == Role.Secretary || posterRole == Role.Admin) authorizedApps.add(Applications.MANAGECOURSES); + + if (posterRole == Role.InscriptionService || posterRole == Role.Admin) authorizedApps.add(Applications.INSCRIPTION); + + return authorizedApps; + } + +} \ No newline at end of file diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java new file mode 100644 index 0000000..445a928 --- /dev/null +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java @@ -0,0 +1,24 @@ +package ovh.herisson.Clyde.Tables; + +public enum Applications { + // without any token + LOGIN, + + // with any token + PROFILE, + + + // Students and higher authorization + MSG, + FORUM, + RDV, + + // teachers and Secretary authorization + MANAGECOURSES, + + // InscriptionService authorization + INSCRIPTION; + + + +} -- 2.46.0 From 208c6c63e841daf5d2ff49f09dc1dbaa24c25163 Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sat, 16 Mar 2024 00:31:03 +0100 Subject: [PATCH 2/7] moved the isSecretaryOrAdmin method --- .../Clyde/EndPoints/InscriptionController.java | 15 ++------------- .../herisson/Clyde/EndPoints/UserController.java | 16 ++-------------- .../Clyde/Services/AuthenticatorService.java | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 27 deletions(-) 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 a997c54..67ca1ee 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/InscriptionController.java @@ -31,7 +31,7 @@ public class InscriptionController { @GetMapping("/inscriptionRequests") 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<>(); @@ -70,15 +70,4 @@ public class InscriptionController { toReturn.put("state", inscriptionRequest.getState()); return toReturn; } - - - 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; - } -} +} \ No newline at end of file diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java index 844e82e..d797284 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/UserController.java @@ -43,7 +43,7 @@ public class UserController { @PostMapping("/user") public ResponseEntity postUser(@RequestBody User user,@RequestHeader("Authorization") String authorization){ - if (!isSecretaryOrAdmin(authorization)) + if (authServ.isNotSecretaryOrAdmin(authorization)) return new UnauthorizedResponse<>(null); userService.save(user); @@ -53,7 +53,7 @@ public class UserController { @GetMapping("/users") public ResponseEntity>> getAllUsers(@RequestHeader("Authorization") String authorization){ - if (!isSecretaryOrAdmin(authorization)) + if (authServ.isNotSecretaryOrAdmin(authorization)) return new UnauthorizedResponse<>(null); Iterable users = userService.getAll(); @@ -85,7 +85,6 @@ public class UserController { */ private HashMap userWithoutPassword(User user){ HashMap toReturn = new HashMap<>(); - toReturn.put("regNo",user.getRegNo()); toReturn.put("firstName",user.getFirstName()); toReturn.put("lastName",user.getLastName()); @@ -93,18 +92,7 @@ public class UserController { toReturn.put("country",user.getCountry()); toReturn.put("address",user.getAddress()); toReturn.put("role",user.getRole()); - return toReturn; } - - 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/Services/AuthenticatorService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java index 60dc6bc..1cc18e1 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java @@ -4,6 +4,7 @@ import org.springframework.stereotype.Service; import ovh.herisson.Clyde.EndPoints.LoginController; import ovh.herisson.Clyde.Repositories.InscriptionRepository; import ovh.herisson.Clyde.Tables.InscriptionRequest; +import ovh.herisson.Clyde.Tables.Role; import ovh.herisson.Clyde.Tables.Token; import ovh.herisson.Clyde.Tables.User; @@ -39,4 +40,17 @@ public class AuthenticatorService { public void register(InscriptionRequest inscriptionRequest) { inscriptionService.save(inscriptionRequest); } + + + public boolean isNotSecretaryOrAdmin(String authorization){ + if (authorization ==null) + return true; + + User poster = getUserFromToken(authorization); + if (poster == null) return true; + + return poster.getRole() != Role.Secretary || poster.getRole() != Role.Admin; + } + } + -- 2.46.0 From 25009ba149938c74594d53088e7c52ea5ad0fd16 Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sat, 16 Mar 2024 00:34:20 +0100 Subject: [PATCH 3/7] Enum in CamelCase --- .../Clyde/EndPoints/ApplicationsController.java | 14 +++++++------- .../ovh/herisson/Clyde/Tables/Applications.java | 17 +++++++---------- .../ovh/herisson/Clyde/Tables/CursusType.java | 6 +++--- .../ovh/herisson/Clyde/Tables/RequestState.java | 2 +- .../java/ovh/herisson/Clyde/Tables/Role.java | 4 ++-- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java index d044bf7..9bd32c1 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/ApplicationsController.java @@ -44,17 +44,17 @@ public class ApplicationsController { Role posterRole = authServ.getUserFromToken(token).getRole(); ArrayList authorizedApps = new ArrayList<>(); - authorizedApps.add(Applications.LOGIN); - authorizedApps.add(Applications.PROFILE); - authorizedApps.add(Applications.MSG); - authorizedApps.add(Applications.FORUM); - authorizedApps.add(Applications.RDV); + authorizedApps.add(Applications.Login); + authorizedApps.add(Applications.Profile); + authorizedApps.add(Applications.Msg); + authorizedApps.add(Applications.Forum); + authorizedApps.add(Applications.Rdv); if (posterRole == Role.Student || posterRole == Role.Admin) return authorizedApps; - if (posterRole == Role.Teacher || posterRole == Role.Secretary || posterRole == Role.Admin) authorizedApps.add(Applications.MANAGECOURSES); + if (posterRole == Role.Teacher || posterRole == Role.Secretary || posterRole == Role.Admin) authorizedApps.add(Applications.ManageCourses); - if (posterRole == Role.InscriptionService || posterRole == Role.Admin) authorizedApps.add(Applications.INSCRIPTION); + if (posterRole == Role.InscriptionService || posterRole == Role.Admin) authorizedApps.add(Applications.Inscription); return authorizedApps; } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java index 445a928..6ad6567 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Applications.java @@ -2,23 +2,20 @@ package ovh.herisson.Clyde.Tables; public enum Applications { // without any token - LOGIN, + Login, // with any token - PROFILE, + Profile, // Students and higher authorization - MSG, - FORUM, - RDV, + Msg, + Forum, + Rdv, // teachers and Secretary authorization - MANAGECOURSES, + ManageCourses, // InscriptionService authorization - INSCRIPTION; - - - + Inscription } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusType.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusType.java index 5e9c50f..d99d47e 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusType.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/CursusType.java @@ -2,7 +2,7 @@ package ovh.herisson.Clyde.Tables; public enum CursusType { - infoBab1, - chemistryBab1, - psychologyBab1; + InfoBab1, + ChemistryBab1, + PsychologyBab1 } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/RequestState.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/RequestState.java index f0345c1..d52f1c9 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/RequestState.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/RequestState.java @@ -3,5 +3,5 @@ package ovh.herisson.Clyde.Tables; public enum RequestState { Accepted, Refused, - Pending; + Pending } diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java index 4e4469b..f6f8967 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Role.java @@ -5,5 +5,5 @@ public enum Role { Student, Admin, InscriptionService, - Secretary; -} + Secretary +} \ No newline at end of file -- 2.46.0 From 13fd048cd28f2efc59a6b7a4112343761aed28b9 Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sat, 16 Mar 2024 09:01:36 +0100 Subject: [PATCH 4/7] added a inscriptionService mock user --- .../main/java/ovh/herisson/Clyde/EndPoints/MockController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java index 136cecd..f3ea51d 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java +++ b/backend/src/main/java/ovh/herisson/Clyde/EndPoints/MockController.java @@ -43,7 +43,8 @@ public class MockController { User joe = new User("Mama","Joe","student@student.com","roundabout","DaWarudo",new Date(0), null,Role.Student,passwordEncoder.encode("student")); User meh = new User("Inspiration","lackOf","secretary@secretary.com","a Box","the street",new Date(0), null,Role.Teacher,passwordEncoder.encode("secretary")); User joke = new User("CthemBalls","Lemme","teacher@teacher.com","lab","faculty",new Date(0), null,Role.Teacher,passwordEncoder.encode("teacher")); - mockUsers = new ArrayList(Arrays.asList(herobrine,joe,meh,joke)); + User lena = new User("Louille","Lena","inscriptionService@InscriptionService.com","no","yes",new Date(0), null,Role.Teacher,passwordEncoder.encode("inscriptionService")); + mockUsers = new ArrayList<>(Arrays.asList(herobrine,joe,meh,joke)); userRepo.saveAll(mockUsers); } -- 2.46.0 From c6198b7220931156195ebeb7901cd3cda13dd926 Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sat, 16 Mar 2024 09:02:08 +0100 Subject: [PATCH 5/7] cleaned Services + added private final to all repos --- .../Clyde/Services/AuthenticatorService.java | 2 -- .../herisson/Clyde/Services/InscriptionService.java | 13 +++++-------- .../ovh/herisson/Clyde/Services/StorageService.java | 2 -- .../ovh/herisson/Clyde/Services/TokenService.java | 4 +--- .../main/java/ovh/herisson/Clyde/Tables/Course.java | 2 +- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java index 1cc18e1..a3301c1 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/AuthenticatorService.java @@ -1,8 +1,6 @@ package ovh.herisson.Clyde.Services; import org.springframework.stereotype.Service; -import ovh.herisson.Clyde.EndPoints.LoginController; -import ovh.herisson.Clyde.Repositories.InscriptionRepository; import ovh.herisson.Clyde.Tables.InscriptionRequest; import ovh.herisson.Clyde.Tables.Role; import ovh.herisson.Clyde.Tables.Token; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java index 45495b7..318dfc1 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/InscriptionService.java @@ -4,23 +4,20 @@ import org.springframework.stereotype.Service; import ovh.herisson.Clyde.Repositories.InscriptionRepository; import ovh.herisson.Clyde.Tables.InscriptionRequest; -import java.util.HashMap; -import java.util.Map; - @Service public class InscriptionService { - InscriptionRepository incriptionRepo; + private final InscriptionRepository inscriptionRepo; public void save(InscriptionRequest inscriptionRequest){ - incriptionRepo.save(inscriptionRequest); + inscriptionRepo.save(inscriptionRequest); } public InscriptionService(InscriptionRepository inscriptionRepo){ - this.incriptionRepo = inscriptionRepo; + this.inscriptionRepo = inscriptionRepo; } public InscriptionRequest getById(long id){ - InscriptionRequest inscriptionRequest = incriptionRepo.findById(id); + InscriptionRequest inscriptionRequest = inscriptionRepo.findById(id); if (inscriptionRequest == null){ return null; @@ -29,6 +26,6 @@ public class InscriptionService { } public Iterable getAll(){ - return incriptionRepo.findAll(); + return inscriptionRepo.findAll(); } } \ No newline at end of file diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java index c7f8d1b..fb04f68 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/StorageService.java @@ -4,10 +4,8 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import ovh.herisson.Clyde.Repositories.FileRepository; import ovh.herisson.Clyde.Tables.*; - import java.io.File; import java.io.IOException; - import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java b/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java index 50ddcbf..ce0d109 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Services/TokenService.java @@ -5,16 +5,14 @@ import org.springframework.stereotype.Service; import ovh.herisson.Clyde.Repositories.TokenRepository; import ovh.herisson.Clyde.Tables.Token; import ovh.herisson.Clyde.Tables.User; - import java.io.UnsupportedEncodingException; import java.security.SecureRandom; import java.util.ArrayList; import java.util.Calendar; -import java.util.Date; @Service public class TokenService { - TokenRepository tokenRepo; + private final TokenRepository tokenRepo; public TokenService(TokenRepository tokenRepo){ this.tokenRepo = tokenRepo; diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java index 54e167a..fb11604 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java @@ -1,6 +1,6 @@ package ovh.herisson.Clyde.Tables; -import jakarta.persistence.Entity; +import ja karta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; -- 2.46.0 From 8f2fb041129f83e717d2b382b831f47b4eef1a7f Mon Sep 17 00:00:00 2001 From: Bartha Maxime <231026@umons.ac.be> Date: Sat, 16 Mar 2024 09:03:03 +0100 Subject: [PATCH 6/7] I pressed tab by accident --- backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java b/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java index fb11604..54e167a 100644 --- a/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java +++ b/backend/src/main/java/ovh/herisson/Clyde/Tables/Course.java @@ -1,6 +1,6 @@ package ovh.herisson.Clyde.Tables; -import ja karta.persistence.Entity; +import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; -- 2.46.0 From da3f8c47f95972f78ca760b9328b2ff235b43e44 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Sat, 16 Mar 2024 14:22:13 +0100 Subject: [PATCH 7/7] 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 +} -- 2.46.0