Last active
August 29, 2015 14:02
-
-
Save MilanGrubnic70/1ae53e1d566ad9872e41 to your computer and use it in GitHub Desktop.
Controller File
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
get '/' do | |
# Look in app/views/index.erb | |
erb :index | |
end | |
get '/signin' do | |
user = User.authenticate(params[:email], params[:password]) | |
if user | |
session[:user_id] = user.id | |
redirect /"secure_area" | |
else | |
@errors = "Your signin and/or password are incorrect." | |
erb: :signin | |
end | |
end | |
get '/logout' do | |
session[:user_id] = nil use this | |
# session.delete(:user_id) or use this | |
# sesson.clear clears the all data including shopping cart | |
end | |
get '/secure_area' do | |
if session[:user_id] | |
erb: secure_things | |
else | |
redirect to '/signin' | |
end | |
end | |
get '/secure_area' do | |
if current_user | |
erb: secure_things | |
else | |
redirect '/' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment