Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Signing out User with Devise is signing out the AdminUser as well

I am using Devise for my User model. I am also using ActiveAdmin which is using Devise as well for the AdminUser model.

I can sign in using an admin_user and a user independently of each other, but I have noticed if I sign out the User, the AdminUser is signed out as well. The same thing happens if I reverse it and sign out the AdminUser first.

What can I do to hopefully get around this?

routes.rb

devise_for :admin_users, ActiveAdmin::Devise.config
devise_for :users
get "dashboard/home"

ApplicationController

protected

def after_sign_in_path_for(resource)
  if resource.is_a?(User)
    stored_location_for(:user) || dashboard_home_path
  elsif resource.is_a?(AdminUser)
    stored_location_for(:admin_user) || admin_root_path(resource)
  end
end
like image 867
Craig McGuff Avatar asked Nov 13 '12 10:11

Craig McGuff


1 Answers

What you are looking for is a Devise configuration called sign_out_all_scopes

When a user signs out and it is set to true, all scopes are signed out for this user, both user and admin in your case.

In devise.rb search for sign_out_all_scopes and change its value to true.

like image 77
Erez Rabih Avatar answered Oct 07 '22 21:10

Erez Rabih