wedding-planner/app/controllers/sessions_controller.rb
Manuel Bustillo a30328305f Revert "Refine controllers"
This reverts commit 3e38630eb45ec494e25aa9fb3435e8b7655a60a6.
2024-11-30 10:44:21 +01:00

24 lines
635 B
Ruby

# Copyright (C) 2024 Manuel Bustillo
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." }
def new
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