1
0
forked from PGL/Clyde

Fix merge because i'm bad

This commit is contained in:
Debucquoy Anthony 2024-03-16 14:22:13 +01:00
parent 1546fc6d47
commit da3f8c47f9
Signed by untrusted user: 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;
} }