check_authorization causes custom devise controller to fail?

て烟熏妆下的殇ゞ 提交于 2021-01-07 02:52:34

问题


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:

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


回答1:


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.



来源:https://stackoverflow.com/questions/64520705/check-authorization-causes-custom-devise-controller-to-fail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!