Class: SwitchUser::Provider::Devise

Inherits:
Base
  • Object
show all
Defined in:
lib/switch_user/provider/devise.rb

Instance Method Summary collapse

Methods inherited from Base

#clear_original_user, #current_user?, #current_users_without_scope, #login_exclusive, #login_inclusive, #logout_all, #original_user, #original_user=, #remember_current_user

Constructor Details

#initialize(controller) ⇒ Devise

Returns a new instance of Devise.



6
7
8
9
# File 'lib/switch_user/provider/devise.rb', line 6

def initialize(controller)
  @controller = controller
  @warden = @controller.warden
end

Instance Method Details

#current_user(scope = nil) ⇒ Object



23
24
25
# File 'lib/switch_user/provider/devise.rb', line 23

def current_user(scope = nil)
  @warden.user(scope)
end

#login(user, scope = nil) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/switch_user/provider/devise.rb', line 11

def (user, scope = nil)
  if SwitchUser.provider.is_a?(Hash) && SwitchUser.provider[:store_sign_in]
    @warden.set_user(user, scope: scope)
  else
    @warden.session_serializer.store(user, scope)
  end
end

#logout(scope = nil) ⇒ Object



19
20
21
# File 'lib/switch_user/provider/devise.rb', line 19

def logout(scope = nil)
  @warden.logout(scope)
end