Files
fizzy/app/controllers/sessions_controller.rb
T
David Heinemeier Hansson b53a2b8880 Fix url reference
2024-10-19 19:07:48 -07:00

29 lines
758 B
Ruby

class SessionsController < ApplicationController
allow_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." }
before_action :require_first_run_completion
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 new_session_path
end
private
def require_first_run_completion
redirect_to first_run_path if Account.none?
end
end