Allow Transition based on role


#1

I would like to allow certain transitions to take place only if the current user is authorized to go there.

These routes are all subclassed/extended from a top-level gateway guard route, and within this route I need to find out the destination (already know current user and role).

I want to abort the transition and push him back where he came from, with an optional error message if not too secret.

What is the ember way for doing this?


#2

Maybe not the best way to do it but I would use the beforeModel hook for that purpose. I would keep each route permission checking independent in order to change it in case you want manage permissions differently in the near future.


#3

Yes I agree that that would be one possible way, but it doesn’t make the management of allowed transitions any easier.

My goal was to be able to define this in a centralized place, and via some kind of permissions matrix allow/disallow transitions based on the role the logged in person has.

Maybe an interesting addon?


#4

Then you should probably define the logic in a service (which you can easily inject into your routers).


#5

Sounds interesting, any tips on where I should look?


#6

I’m also interested in create an addon with this functionality. But I don’t see an efficient way to define the permissions matrix in a centralized, agnostic way.

Any ideas?