问题
I am using devise with activeadmin and one other model. If I open both interfaces on browser and logout from one it will also destroy other sessions.
Started GET "/admin/logout" for 127.0.0.1 at 2015-11-03 19:45:25 +0500
Processing by ActiveAdmin::Devise::SessionsController#destroy as HTML
Parameters: {"authenticity_token"=>"6rqzYcjQNgm8sOcAy2ItHvqGWTYyUBEK2tE+hJi8Ti0E25qJLR+vdA9W++HHtFaD3CpBtnNAn6xbhS6mr8YLTQ=="}
Teacher Load (30.4ms) SELECT `teachers`.* FROM `teachers` WHERE `teachers`.`id` = ? ORDER BY `teachers`.`id` ASC LIMIT 1 [["id", 1]]
AdminUser Load (0.2ms) SELECT `admin_users`.* FROM `admin_users` WHERE `admin_users`.`id` = ? ORDER BY `admin_users`.`id` ASC LIMIT 1 [["id", 1]]
SQL (0.1ms) BEGIN
(0.0ms) COMMIT
SQL (0.0ms) BEGIN
(0.0ms) COMMIT
回答1:
By default when Devise::SessionsController#destroy
is invoked it will destroy the sessions from all scopes. This is configurable via sign_out_all_scopes
. So to disable it, set it to false:
# config/initializers/devise.rb
config.sign_out_all_scopes = false
来源:https://stackoverflow.com/questions/33502026/logout-from-activeadmin-destroy-other-sessions