CELLL Flashcards

1
Q

def current_user

A

@current_user ||=User.find_by(session_token: session[:session_token])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

def log_in!

A
def log_in!(user)
session[:session_token] = user.reset_session_token!
@current_user = user
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

def log_out!

A

current_user.reset_session_token!
session[:session_token] = nil
@current_user = nil

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

def logged_in?

A

!!current_user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

def ensure_signed_in!/require_signed_in!

A

redirect_to new_session_url unless signed_in?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly