Files
fizzy/app/controllers/sessions_controller.rb
T
2025-09-13 16:03:02 -04:00

22 lines
601 B
Ruby

class SessionsController < ApplicationController
require_unauthenticated_access only: %i[ new create ]
rate_limit to: 10, within: 3.minutes, only: :create, with: -> { redirect_to new_session_path, alert: "Try again later." }
def new
end
def create
if user = User.active.authenticate_by(params.permit(:email_address, :password))
start_new_session_for user
redirect_to after_authentication_url
else
redirect_to new_session_path, alert: "Try another email address or password."
end
end
def destroy
terminate_session
redirect_to_logout_url
end
end