-
Notifications
You must be signed in to change notification settings - Fork 603
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
Upgrading to 3.1 best practices. #2275
Comments
A good practice is to wrapper authenticated routes: Router.map(function() {
this.route('login');
this.route('authenticated', { path: '/' }, function() {
// your authenticated routes.
});
}); If you can not do that, your approach should work.
That is the expected behavior. The |
@alejandrodevs the backed does return a 401 and the ember-simple-auth used to handle the error using the application route mixin. Should this error be handled in the application route or the data adapter? |
Ember simple auth handles 401 in the DataAdapterMixin which is not longer recommended because Mixins deprecation. Now you can remove completely the mixin and add this to your application adapter: handleResponse(status, ...manyMoreArgs) {
if (status === 401) this.session.invalidate();
return super.handleResponse(...arguments);
} |
@alejandrodevs thank you. This should be added to the readme. |
I am upgrading from 3.0 to 3.1 and it appears that the preferred method to authenticate routes is to nest the routes under an authenticated parent route.
So in order to do this migration I would have to move all my routes, controllers, templates and rename all transition to functions.
I wouldn't have a problem with this but in this case all routes are authenticated except for one login page.
It seems like there should be a way to use the applications route
beforeModel
hook to do the authentication and skip it only on the login route.I was hoping the following would work but it is buggy. It works on page load but if you transition to a route after after the application has loaded it is not requiring authentication.
Is there any other way to pull this off without reworking my whole application?
Thanks for taking the time to look at this.
~ aaron
The text was updated successfully, but these errors were encountered: