Module: Authem::Controller::SessionManagementMethods

Defined in:
lib/authem/controller.rb

Instance Method Summary collapse

Instance Method Details

#clear_all_sessions_for(model, options = {}) ⇒ Object



19
20
21
22
# File 'lib/authem/controller.rb', line 19

def clear_all_sessions_for(model, options={})
  role = options.fetch(:as){ self.class.authem_role_for(model) }
  public_send "clear_all_#{role}_sessions_for", model
end

#redirect_back_or_to(url, options = {}) ⇒ Object



24
25
26
27
# File 'lib/authem/controller.rb', line 24

def redirect_back_or_to(url, options={})
  url = session.delete(:return_to_url) || url
  redirect_to url, options
end

#sign_in(model, options = {}) ⇒ Object



8
9
10
11
12
# File 'lib/authem/controller.rb', line 8

def (model, options={})
  role = options.fetch(:as){ self.class.authem_role_for(model) }
  session.delete :_csrf_token if session.respond_to?(:delete)
  public_send "sign_in_#{role}", model, options
end

#sign_out(model, options = {}) ⇒ Object



14
15
16
17
# File 'lib/authem/controller.rb', line 14

def sign_out(model, options={})
  role = options.fetch(:as){ self.class.authem_role_for(model) }
  public_send "sign_out_#{role}"
end