Created
January 22, 2016 23:11
-
-
Save jkarnowski/2ed2deef50362f8696e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SESSIONS | |
# where did you enable sessions? | |
# WHAT REQUEST ALLOWS A USER TO LOGIN? | |
get '/sessions/new' do | |
erb :'users/login' | |
end | |
# WHAT REQUEST SENDS THE USER DATA TO SET THE SESSION? | |
# example without implementing BCrypt | |
post '/sessions' do | |
user = User.find_by(email: params[:email]) | |
if user && user.password == params[:password] | |
login(user) | |
redirect '/' | |
else | |
erb :'users/login' | |
end | |
end | |
# WHAT REQUEST WILL FORCE A SESSION TO END? | |
get '/logout' do | |
logout! | |
end | |
# BONUS: WHAT REQUEST ALLOWS US TO INSPECT THE SESSION? | |
get '/session-viewer' do | |
session.inspect | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment