Merge branch 'master' into Max/Backend/AppsController
This commit is contained in:
@ -31,23 +31,32 @@ public class ApplicationsController {
|
||||
return new ResponseEntity<>(getAuthorizedApplications(token), HttpStatus.OK);
|
||||
}
|
||||
|
||||
private ArrayList<Applications> getAuthorizedApplications(String token){
|
||||
@GetMapping("/apps/{identifier}")
|
||||
public ResponseEntity<Boolean> 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<Applications> getAuthorizedApplications(String token){
|
||||
Role posterRole = authServ.getUserFromToken(token).getRole();
|
||||
ArrayList<Applications> authorizedApps = new ArrayList<>();
|
||||
|
||||
authorizedApps.add(Applications.LOGIN);
|
||||
authorizedApps.add(Applications.PROFILE);
|
||||
authorizedApps.add(Applications.Login);
|
||||
authorizedApps.add(Applications.Profile);
|
||||
|
||||
if (posterRole == Role.Teacher || posterRole == Role.Student || posterRole == Role.Admin){
|
||||
authorizedApps.add(Applications.MSG);
|
||||
authorizedApps.add(Applications.FORUM);
|
||||
authorizedApps.add(Applications.RDV);
|
||||
authorizedApps.add(Applications.Msg);
|
||||
authorizedApps.add(Applications.Forum);
|
||||
authorizedApps.add(Applications.Rdv);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user