1
0
forked from PGL/Clyde

trop de truc

This commit is contained in:
2024-03-17 21:38:10 +01:00
32 changed files with 521 additions and 307 deletions

View File

@ -30,7 +30,6 @@ public class ApplicationsController {
*/
@GetMapping("/apps")
public ResponseEntity<Iterable<Applications>> getAuthorizedApps(@RequestHeader("Authorization") String token){
return new ResponseEntity<>(getAuthorizedApplications(token), HttpStatus.OK);
}
@ -46,31 +45,32 @@ public class ApplicationsController {
public ArrayList<Applications> getAuthorizedApplications(String token){
ArrayList<Applications> authorizedApps = new ArrayList<>();
//if unAuthed
authorizedApps.add(Applications.Login);
authorizedApps.add(Applications.Profile);
User user = authServ.getUserFromToken(token);
if(user == null)
return authorizedApps;
return authorizedApps;
// if authed
authorizedApps.add(Applications.Profile);
Role posterRole = user.getRole();
Role posterRole = user.getRole();
if (posterRole == Role.Teacher || posterRole == Role.Student || posterRole == Role.Admin){
if (!authServ.isNotIn(new Role[]{Role.Teacher,Role.Student,Role.Admin},token)) {
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 Teacher or Secretary or Admin add ManageCourses App
if (!authServ.isNotIn(new Role[]{Role.Teacher,Role.Secretary,Role.Admin},token))
authorizedApps.add(Applications.ManageCourses);
if (posterRole == Role.InscriptionService || posterRole == Role.Admin) {
authorizedApps.add(Applications.Inscription);
authorizedApps.add(Applications.StudentsList);
}
if (!authServ.isNotIn(new Role[]{Role.InscriptionService,Role.Admin},token)){
authorizedApps.add(Applications.Inscription);
authorizedApps.add(Applications.StudentsList);}
if (posterRole == Role.Secretary || posterRole == Role.Admin){
if (!authServ.isNotIn(new Role[]{Role.Secretary,Role.Admin},token)){
authorizedApps.add(Applications.UsersList);}
return authorizedApps;
}