I am trying to create role based authentication and show an available content for user role. I have the following code in my route.js
Application.config(function($routeProvider, $locationProvider) {
var role = ... ???
if(role === 'ADMIN') {
$routeProvider
.when('/dashboard', {
templateUrl: "views/adminDashboard.html",
controller: "adminDashboardController"
});
}
if(role === 'USER') {
$routeProvider
.when('/dashboard', {
templateUrl: "views/userDashboard.html",
controller: "userDashboardController"
});
}
});
How can I get role for user? I have an enpoint /user/me
which returns current user's role but I can't do http here.