Class: SwitchUser::Provider::Authlogic

Inherits:
Base
  • Object
show all
Defined in:
lib/switch_user/provider/authlogic.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) ⇒ Authlogic

Returns a new instance of Authlogic.



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

def initialize(controller)
  @controller = controller
end

Instance Method Details

#current_user(_scope = nil) ⇒ Object



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

def current_user(_scope = nil)
  result = UserSession.find
  result&.record
end

#login(user, _scope = nil) ⇒ Object



10
11
12
# File 'lib/switch_user/provider/authlogic.rb', line 10

def (user, _scope = nil)
  UserSession.create(user)
end

#logout(_scope = nil) ⇒ Object



14
15
16
# File 'lib/switch_user/provider/authlogic.rb', line 14

def logout(_scope = nil)
  @controller.current_user_session.destroy
end