RafaelVidaurre / angular-permission

Simple route authorization via roles/permissions
MIT License
1.13k stars 212 forks source link

permission-sref state params #442

Open Jcbobo opened 6 years ago

Jcbobo commented 6 years ago

Hello, I need to set up a permission based on state parameters not only to state name, brief example you can access the state /places/:id only if the id is related to you. I was able to handle this at steate level then i move to view level.

there are already some closed issues about this, but asking for "extra" stuff #431, #434 basically the problem is the same, handling permission based on some "data" constraint, that can be handled in states but not in views (at the moment)

  1. try dynamic roles name try to create roles like house_id but not able to use it in permission-only
  2. try static roles with parameter based validation, the validate role funtcion has no parameter and look at global obj PermTransitionProperties popolated on state change (and only on state change)
  3. try to modified permission directive for override PermTransitionProperties but having two permission permission-sref usage in the same view take only the latest value of parameters (is a global object so is normal)

I think that having the same behavior both in state and view will be a big plus, bur removing the helper and passing to a map PermStatePermissionMap is tricky and can lead to breack compatibility, what is your idea about that?

-----edit modified authorizeByStateName passing extra params (options) that is propagated untile role/permission validation function (if not passed the helper for transition will be present), i will submit a PR in few