diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-03-04 10:57:54 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-03-04 10:57:54 -0500 |
commit | 1d90f33bf07f9610d358c6c9c56754784b050541 (patch) | |
tree | 4d7385e543e0ed77d43a7ed8fd4045087f17848a /app/controllers/sessions_controller.rb | |
parent | 42cf035f9023e773a20d2b14a984ba0a5fef9c60 (diff) |
simplify the sessions routing
Diffstat (limited to 'app/controllers/sessions_controller.rb')
-rw-r--r-- | app/controllers/sessions_controller.rb | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 3417332..fa5d024 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,25 +1,28 @@ class SessionsController < ApplicationController + # GET /sessions/new def new if @user.nil? @user = User.new end end - # find the user and create a new session - def create - @user = User.find_by(email: params[:session][:email].downcase) - if @user && @user.authenticate(params[:session][:password]) + # POST /sessions + def create + # find the user... + @user = User.find_by(email: params[:session][:email].downcase) + # ... and create a new session + if @user && @user.authenticate(params[:session][:password]) sign_in @user - redirect_to root_path - else - redirect_to signin_path + redirect_to root_path + else + redirect_to new_session_path + end end - end + # DELETE /sessions/current def destroy - sign_out - redirect_to root_path + sign_out + redirect_to root_path end - end |