How can I add authorization to AngularJS and ui.router? I'm using the modulg ng-oauth https://github.com/andreareginato/oauth-ng
Can I use the following examples from the page http://andreareginato.github.io/oauth-ng/?
$scope.$on('oauth:login', function(event, token) {
console.log('Authorized third party app with token', token.access_token);
});
$scope.$on('oauth:logout', function(event) {
console.log('The user has signed out');
});
$scope.$on('oauth:loggedOut', function(event) {
console.log('The user is not signed in');
});
$scope.$on('oauth:denied', function(event) {
console.log('The user did not authorize the third party app');
});
$scope.$on('oauth:expired', function(event) {
console.log('The access token is expired. Please refresh.');
});
$scope.$on('oauth:profile', function(profile) {
console.log('User profile data retrieved: ', profile);
});
Thanks, Simon
You could create some constant roles like this:
Add this custom data/constants to your states:
So when you authenticate and retrieve these roles from your database you can store this in your user object and session so you can eventually verify this when a route changes...
In your auth service (apart from logging in, logging out etc...) you add the following methods.
So when you change the route in the applications
.run
block validation occurs and prevention is possible.Ofcourse this is just an example and bear in mind there are other solutions.