-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sample JWT authenticated routes for angular #223
Comments
How I did it was by adding this to the routes.js.
and then just adding:
To each state definition needing the user to be logged in before accessing. Cheers! |
@jadjoubran I would do it like described here https://medium.com/@petehouston/protect-authentication-routes-in-angular-ui-router-and-satellizer-7745257a7e6#.jmmnk113t, If you like I could submit a pull request for this 😉 |
hmm why not use |
@kujtimiihoxha I think I tried that prior to the one I suggested, but couldn't get it to work properly. @jadjoubran That's awesome! I could finally pull off something I've been wanting to do for a while now: authorization levels. Sweet, thanks!! |
Actually @kujtimiihoxha after thinking about it, with the
|
@jadjoubran how would we implement this with satellizer ? I do not have any experience with satellizer . |
Indeed.. with the current settings, satellizer only gives us whether the user is logged in or not.. but we cannot provide multi-user types auth out of the box, because it's not always the case |
Exactly! Using my method of tapping into the transition of $state, we could
|
I added the generic functionality in routes.run.. you can easily add your own logic if you have multi-user auth Let me know what you think! |
@jadjoubran I have noticed that there is a very cool feature added with your solution that makes it very easy to add routes to authenticated routes, you can add an abstract state ex. .state('admin', {
abstract: true,
data: {
auth: true
},
views: {
header: {
templateUrl: getAdminView('header')
},
footer: {
templateUrl: getAdminView('footer')
},
main: {}
}
})
.state('admin.dashboard', {
url: '/admin/dashboard',
data: {
test: 'test'
},
views: {
'main@': {
templateUrl: getAdminView('dashboard')
}
}
}) here you can see an example, of this feature, also even if you add extra data to the |
Indeed 😄 ui-router makes these things amazingly simple I am trying to stay away from baking in And yes the PR would be great (to redirect to login) 😄 |
@jadjoubran Ok than I thought since it is very easy to implement to add this as an example. But anyway I will submit the PR for the login redirection. |
HI, how can I implement this on the backend
|
As suggested by @iannazzi
Following #202 and #129
it makes sense to have a ui router setup for routes requiring authentication
The text was updated successfully, but these errors were encountered: