Files
puzzle-scoreboard/app/controllers/sessions_controller.rb
sto 6aba5547f2
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
Fix session creation warning
2026-04-22 13:27:14 +02:00

25 lines
772 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 = "Puzzle scoreboard"
end
def create
if user = User.authenticate_by(params.except(:authenticity_token, :commit).permit(:email_address, :password))
start_new_session_for user
redirect_to after_authentication_url, notice: t("sessions.new.notice")
else
@title = "Puzzle scoreboard"
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