Module: Sorcery::Controller::Submodules::RememberMe::InstanceMethods

Defined in:
lib/sorcery/controller/submodules/remember_me.rb

Instance Method Summary collapse

Instance Method Details

#auto_login(user, should_remember = false) ⇒ Object

Override. logins a user instance, and optionally remembers him.



50
51
52
53
54
# File 'lib/sorcery/controller/submodules/remember_me.rb', line 50

def (user, should_remember = false)
  session[:user_id] = user.id.to_s
  @current_user = user
  remember_me! if should_remember
end

#force_forget_me!Object

Clears the cookie, and clears the token value.



43
44
45
46
# File 'lib/sorcery/controller/submodules/remember_me.rb', line 43

def force_forget_me!
  current_user.force_forget_me!
  cookies.delete(:remember_me_token, domain: Config.cookie_domain)
end

#forget_me!Object

Clears the cookie, and depending on the value of remember_me_token_persist_globally, may clear the token value.



37
38
39
40
# File 'lib/sorcery/controller/submodules/remember_me.rb', line 37

def forget_me!
  current_user.forget_me!
  cookies.delete(:remember_me_token, domain: Config.cookie_domain)
end

#remember_me!Object

This method sets the cookie and calls the user to save the token and the expiration to db.



31
32
33
34
# File 'lib/sorcery/controller/submodules/remember_me.rb', line 31

def remember_me!
  current_user.remember_me!
  set_remember_me_cookie!(current_user)
end