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

Adding custom method to get the current user #37

Closed ValMilkevich closed 7 years ago

pokonski commented 7 years ago

I explicitly didn't want to do this, since you can basically override current_policy in your Controllers and provide custom user instead of current_user. Much easier and less indirection.

Your way would be like this:

  1. call to current_policy inside your controller
  2. call to current_user inside AccessGranted
  3. which again calls current_user in the controller.

By overriding the method you can go down to just one step

  1. call to current_policy which uses current_user in the same scope.
pokonski commented 7 years ago

Closing in favour of an existing simpler solution here: https://github.com/chaps-io/access-granted#customizing-policy