mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-24 17:04:43 +00:00
20 lines
523 B
Ruby
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 |