summaryrefslogtreecommitdiff
path: root/app/controllers/sessions_controller.rb
diff options
context:
space:
mode:
authorTomer Kimia <tkimia@purdue.edu>2014-03-03 21:49:38 -0500
committerTomer Kimia <tkimia@purdue.edu>2014-03-03 21:49:38 -0500
commit661dbaf902d770dfbefa9ba1d9e4c28fc7abf891 (patch)
tree3fe6cba03179cc7d9f515a024b1fec31885ab823 /app/controllers/sessions_controller.rb
parentd5f15d40e0c0168bb430ebae39371590266d0eb5 (diff)
small things
Diffstat (limited to 'app/controllers/sessions_controller.rb')
-rw-r--r--app/controllers/sessions_controller.rb17
1 files changed, 10 insertions, 7 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 68cb949..3417332 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -1,22 +1,25 @@
class SessionsController < ApplicationController
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])
- sign_in user
+ @user = User.find_by(email: params[:session][:email].downcase)
+ if @user && @user.authenticate(params[:session][:password])
+ sign_in @user
redirect_to root_path
else
- render 'new'
- end
+ redirect_to signin_path
+ end
end
def destroy
- sign_out
- redirect_to root_path
+ sign_out
+ redirect_to root_path
end
end