chaps-io / access-granted

Multi-role and whitelist based authorization gem for Rails (and not only Rails!)
MIT License
774 stars 41 forks source link

Allow using :manage in array. #49

Closed Crisfole closed 6 years ago

Crisfole commented 6 years ago

Right now we mostly use access-granted with :create :read :update and :destroy permissions. But sometimes we need a specific added permission (let's say :create_children) where it's doesn't really work to say that a person has permissions on the child-record itself.

Right now the following:

...
can [:manage, :create_children], ParentModel
...

Results in literally adding the [:manage, :create_children] permissions, rather than the expected [:create, :read, :update, :destroy, :create_children] permissions.

This PR fixes that by always turning the permissions into an array. Then it expands :manage to the correct set of permissions.

pokonski commented 6 years ago

Hey Christopher! That is a good change to have, I left one comment, once you fix it we can get it merged :)

Crisfole commented 6 years ago

Done!

Just saw your profile! I lived in Wrocław for 7 years! (W Muchoborzym Małym i w Kuźnikach. Zawsze dobrze spotkać kogoś z Wrocławia. Nie mam dużo okazji mówić po Polsku, przepraszam za błędów gramatyzcznych).

pokonski commented 6 years ago

Small world :D And your Polish is perfectly fine :grin: