-
Notifications
You must be signed in to change notification settings - Fork 415
[question] acl: protect a route #56
Comments
Hi @andresrivas1506 , its already implemented by default, on protected routes you simply add and to show / hide elements use |
Hello @silverbux thanks for your time. Yes, its already implemented, but only using I want to protect the route using permissions: .when('/content', {
resolve : {
'acl' : ['$q', 'AclService', function($q, AclService){
if(AclService.can('view_content')){
// Has proper permissions
return true;
} else {
// Does not have permission
return $q.reject('Unauthorized');
}
}]
}
}); Sorry for my bad english |
I can solve with this: $rootScope.$on('$stateChangeError', function (event, toState, toParams, fromState, fromParams, rejection) {
if (rejection === 'Unauthorized') {
$state.go('app.landing');
}
});
.state('app.somerute', {
url: '/some-route',
resolve : {
'acl' : ['$q', 'AclService', function($q, AclService){
if(AclService.can('some_permission')){
// Has proper permissions
return true;
} else {
// Does not have permission
return $q.reject('Unauthorized');
}
}]
},
data: {
auth: true
},
views: {
'main@app': {
templateUrl: getView('someview')
}
}
}) Thank you @silverbux |
Coolness, or try this approach as well.
then you could add a function on your /angular/run/routes.run.js and call AclService from there. |
very nice that approach, thanks |
can someone help me to use this https://github.com/mikemclin/angular-acl#protect-a-route to protect ui-routes?
The text was updated successfully, but these errors were encountered: