apartment-gem

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

Apartment current_tenant resets to 'public' after failed devise login

时光总嘲笑我的痴心妄想 提交于 2019-12-02 00:53:50
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