puzzle-scoreboard/app/controllers/sessions_controller.rb
sto 7023600cd1
All checks were successful
CI / scan_ruby (push) Successful in 20s
CI / scan_js (push) Successful in 11s
CI / lint (push) Successful in 11s
CI / test (push) Successful in 33s
Setup Faker and Factorybot
2025-03-27 09:27:25 +01:00

24 lines
654 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_url, alert: "Try again later." }
before_action :skip_authorization
def new
@title = "Login"
end
def create
if user = User.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
end