summaryrefslogtreecommitdiff
path: root/app/controllers/sessions_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/sessions_controller.rb')
-rw-r--r--app/controllers/sessions_controller.rb25
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