Apartment current_tenant resets to 'public' after failed devise login

半城伤御伤魂 提交于 2019-12-02 05:34:32

问题


I use Devise for authentication and Apartment for multi-tenancy support on a SAAS app.

After a failed login, devise "redirects" to the login page (Users::SessionsController#new) and the value of Apartment::Tenant.current which was previously set in a TenantElevator middleware goes back to its default value of "public".

This is happening because Devise isn't actally redirecting to the login page but calling the FailureApp (which renders the login page) with a new rack env and returning its response. The new rack app doesn't have TenantElevator middleware so the tenant isn't set within the rack app.

Does anyone have any idea how to fix this? Maybe a way I can add the TenantElevator middleware to the Failure app?

来源:https://stackoverflow.com/questions/40075966/apartment-current-tenant-resets-to-public-after-failed-devise-login

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