CELLL Flashcards
1
Q
def current_user
A
@current_user ||=User.find_by(session_token: session[:session_token])
2
Q
def log_in!
A
def log_in!(user) session[:session_token] = user.reset_session_token! @current_user = user
3
Q
def log_out!
A
current_user.reset_session_token!
session[:session_token] = nil
@current_user = nil
4
Q
def logged_in?
A
!!current_user
5
Q
def ensure_signed_in!/require_signed_in!
A
redirect_to new_session_url unless signed_in?