2024-02-02 09:05:04 -06:00
|
|
|
class SessionsController < ApplicationController
|
|
|
|
layout "auth"
|
2024-02-02 16:06:55 +00:00
|
|
|
|
2024-02-02 09:05:04 -06:00
|
|
|
def new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
if user = User.authenticate_by(email: params[:email], password: params[:password])
|
|
|
|
login user
|
|
|
|
redirect_to root_path
|
|
|
|
else
|
2024-02-03 14:17:49 -06:00
|
|
|
flash.now[:alert] = t(".invalid_credentials")
|
2024-02-02 09:05:04 -06:00
|
|
|
render :new, status: :unprocessable_entity
|
|
|
|
end
|
|
|
|
end
|
2024-02-02 16:06:55 +00:00
|
|
|
|
2024-02-02 09:05:04 -06:00
|
|
|
def destroy
|
|
|
|
logout
|
2024-02-03 14:17:49 -06:00
|
|
|
redirect_to root_path, notice: t(".logout_successful")
|
2024-02-02 09:05:04 -06:00
|
|
|
end
|
|
|
|
end
|