For example, an authenticated user should not see the login form. All of
the solutions I have seen use $locationChangeStart event. I would like to
keep the access check modular and thought it might be best to handle this
in the resolve of the module's $routeProvider, something like:
angular.module('app.users.password', [
'app.users',
'app.form'
])
.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/user/password', {
templateUrl: 'components/users/password/password-form.html',
controller: 'PasswordCtrl',
resolve: {
access: ['Users', function(Users) {
// redirects user based on property
Users.access({
requiresAnon: true
});
}]
}
})
}
])
;
This works in that the redirect happens before the controller gets
instantiated, but there is a GET for password form template -- not
completely horrible, but not desired.
Is there a modular way to do access/authorization checks like this? I am
assuming that checking $locationChangeStart in several modules is not a
good way to go (plus, where would it go if it was?).
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.