cleaned all controllers
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user