I am intercepting the error
hook on my ember routes. I am doing this on top level and inheriting all my routes from this class.
What I want to do is, when the server returns a 401 Unauthorized response, I want to display a notice saying the user is not authorized, and stay on the same page.
So far I have this:
Ember.Route = Ember.Route.extend(InfinityRoute, {
actions: {
error: function(error){
if (error.status === 401) {
this.store.createRecord('notice', {
message: "You are not authorized to view this content. Sorry man."
});
// Some code here ...
}
}
}
});
The notice works, but the application still switches to the new template, which has empty content because the user does not have authorization to view it.
I want my application to stay on the same page and not transition to the requested page.
How?
Aucun commentaire:
Enregistrer un commentaire