1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00
Files
wrestlingdev.com/app/controllers/sessions_controller.rb

20 lines
523 B
Ruby

class SessionsController < ApplicationController
def new
end
def create
user = User.find_by(email: params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
session[:user_id] = user.id
redirect_to root_path, notice: "Logged in successfully"
else
flash.now[:alert] = "Invalid email/password combination"
render 'new'
end
end
def destroy
session.delete(:user_id)
redirect_to root_path, notice: "Logged out successfully"
end
end