Module: Incline::Extensions::Session::Controller

Defined in:
lib/incline/extensions/session.rb

Overview

Contains the methods specific to controllers.

Instance Method Summary collapse

Instance Method Details

#forget(user) ⇒ Object

Removes the user from the permanent cookie store.



97
98
99
100
101
# File 'lib/incline/extensions/session.rb', line 97

def forget(user)
  user.forget
  cookies.delete(user_id_cookie)
  cookies.delete(user_token_cookie)
end

#log_in(user) ⇒ Object

Logs in the given user.



75
76
77
# File 'lib/incline/extensions/session.rb', line 75

def (user)
  session[:user_id] = user.id
end

#log_outObject

Logs out any currently logged in user.



81
82
83
84
85
# File 'lib/incline/extensions/session.rb', line 81

def log_out
  forget current_user
  session.delete(:user_id)
  @current_user = nil
end

#remember(user) ⇒ Object

Stores the user ID to the permanent cookie store to keep the user logged in.



89
90
91
92
93
# File 'lib/incline/extensions/session.rb', line 89

def remember(user)
  user.remember
  cookies.permanent.signed[user_id_cookie] = user.id
  cookies.permanent[user_token_cookie] = user.remember_token
end