Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CanCan example in README causes back action to not be authorized #69

Open
mvz opened this issue May 20, 2020 · 1 comment
Open

CanCan example in README causes back action to not be authorized #69

mvz opened this issue May 20, 2020 · 1 comment

Comments

@mvz
Copy link

mvz commented May 20, 2020

The example in the README for using CanCan suggests the following:

      def masquerade_authorize!
        authorize!(:masquerade, User)
      end

However, the masquerade_authorize! method is also called before the back action. In that case, however, the current user is the unprivileged user, so reverting the masquerade is denied.

@mvz
Copy link
Author

mvz commented May 20, 2020

It looks like the Pundit example gives a possible solution:

      def masquerade_authorize!
        authorize!(:masquerade, User) unless params[:action] == 'back'
      end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant