check_authorization causes custom devise controller to fail?
Asked Answered
S

1

0

Background

I have a simple app with devise and cancancan. Because I wanted to add a little bit of custom logic to the signup process, I used devise with customised controllers, which simply means devise uses the users controller (rather than devise controllers) for all of the things devise does.

Problem

When I add check_authorization to the application controller, and skip_authorization_check to all of the user (devise) controllers, I still get the following error raised when the user tries to sign in or out:

enter image description here

Question

Does anyone know how to skip_authorization_check for these controllers? (I already have skip_authorization_check in every user (devise) controller, I thought that would do it, so I'm not sure what to try

Scend answered 25/10, 2020 at 5:39 Comment(0)
S
0

I found the answer 90% of the way through writing this question, so figured to post it in case it helps others in the future.

The answer is, simply use the same method for skipping authorization checks on devise in the regular way (even if using customised devise controllers), that is, simply add this to the application_controller

check_authorization unless: :devise_controller?

Adding skip_authorization_check manually to each devise (or customised devise) controller does not seem necessary when using this approach.

Scend answered 25/10, 2020 at 5:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.