Fix merge because i'm bad
All checks were successful
Build and test backend / Build-backend (pull_request) Successful in 2m3s
Build and test backend / Test-backend (pull_request) Successful in 2m0s
Build and test FrontEnd / Build-frontend (pull_request) Successful in 22s

This commit is contained in:
Debucquoy Anthony 2024-03-16 14:22:13 +01:00
parent 1546fc6d47
commit da3f8c47f9
Signed by: tonitch
GPG Key ID: A78D6421F083D42E
3 changed files with 3 additions and 27 deletions

View File

@ -43,28 +43,4 @@ public class CurriculumController {
public ResponseEntity<Iterable<CurriculumCourse>> findAll(){ public ResponseEntity<Iterable<CurriculumCourse>> findAll(){
return new ResponseEntity<>(curriculumCourseServ.findAll(),HttpStatus.OK); return new ResponseEntity<>(curriculumCourseServ.findAll(),HttpStatus.OK);
} }
/**@PostMapping("/curriculum")
public ResponseEntity<String> 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;
}
} }

View File

@ -32,7 +32,7 @@ public class InscriptionController {
@GetMapping("/requests/register") @GetMapping("/requests/register")
public ResponseEntity<Iterable<Map<String,Object>>> getAllRequests(@RequestHeader("Authorization") String token){ public ResponseEntity<Iterable<Map<String,Object>>> getAllRequests(@RequestHeader("Authorization") String token){
if (!isSecretaryOrAdmin(token)){return new UnauthorizedResponse<>(null);} if (authServ.isNotSecretaryOrAdmin(token)){return new UnauthorizedResponse<>(null);}
Iterable<InscriptionRequest> inscriptionRequests = inscriptionServ.getAll(); Iterable<InscriptionRequest> inscriptionRequests = inscriptionServ.getAll();
ArrayList<Map<String,Object>> toReturn = new ArrayList<>(); ArrayList<Map<String,Object>> toReturn = new ArrayList<>();
@ -64,7 +64,7 @@ public class InscriptionController {
@RequestHeader("Authorize") String token, @RequestHeader("Authorize") String token,
@RequestBody RequestState requestState) @RequestBody RequestState requestState)
{ {
if (!isSecretaryOrAdmin(token)) return new UnauthorizedResponse<>(null); if (authServ.isNotSecretaryOrAdmin(token)) return new UnauthorizedResponse<>(null);
inscriptionServ.modifyState(id, requestState); inscriptionServ.modifyState(id, requestState);
return null; return null;
} }

View File

@ -49,4 +49,4 @@ public class LoginController {
authServ.register(inscriptionRequest); authServ.register(inscriptionRequest);
return new ResponseEntity<>("Is OK", HttpStatus.OK); return new ResponseEntity<>("Is OK", HttpStatus.OK);
} }
} }