mercredi 30 mars 2016

What is the correct hook for Ember Route to check authorization?

In an Ember.js application, you can use various hooks to check authorization. There are beforeModel, willTransition, redirect hooks on route. also the same events applies on Router.

I'm developing authorization infrastructure for a project. All the route's are written by developers. But an abstract-route (which is extended by all routes) is my code.

  1. If I implement beforeModal or redirect hook in an abstract-route, when a developer writes his own beforeModal methods, my hook will be overwritten.
  2. If I implement willTransition, checking code will be laid on a route that starts transition. From the guide, it seems that willTransition is applicable when leaving the route.
  3. Is it a correct way to handle Router's events?

So what is the correct way to check authorization and abort/prevent transition?




Aucun commentaire:

Enregistrer un commentaire