1
0
forked from PGL/Clyde

cleaned all controllers

This commit is contained in:
2024-03-16 19:13:57 +01:00
parent 069466ef5f
commit 97b57b361d
16 changed files with 181 additions and 126 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,24 +45,29 @@ 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);
if (!authServ.IsNotIn(new Role[]{Role.InscriptionService,Role.Admin},token))
authorizedApps.add(Applications.Inscription);
return authorizedApps;
}