show map by role
This commit is contained in:
@ -2,6 +2,7 @@ package ovh.herisson.Clyde.EndPoints;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
@ -9,10 +10,12 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import ovh.herisson.Clyde.Services.AuthenticatorService;
|
||||
import ovh.herisson.Clyde.Tables.Applications;
|
||||
import ovh.herisson.Clyde.Tables.Role;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(originPatterns = "*", allowCredentials = "true")
|
||||
public class ApplicationsController {
|
||||
|
||||
AuthenticatorService authServ;
|
||||
@ -41,12 +44,17 @@ public class ApplicationsController {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
User user = authServ.getUserFromToken(token);
|
||||
if(user == null)
|
||||
return authorizedApps;
|
||||
|
||||
Role posterRole = user.getRole();
|
||||
|
||||
if (posterRole == Role.Teacher || posterRole == Role.Student || posterRole == Role.Admin){
|
||||
authorizedApps.add(Applications.Msg);
|
||||
authorizedApps.add(Applications.Forum);
|
||||
|
Reference in New Issue
Block a user