summaryrefslogtreecommitdiff
path: root/app/controllers/sessions_controller.rb
blob: 3417332c5b4072de8004281160f4cda1f2f57373 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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
		  redirect_to root_path
    else
		  redirect_to signin_path
	end
  end

	def destroy
    	sign_out
    	redirect_to root_path
	end

end