wedding-planner/app/controllers/sessions_controller.rb
Manuel Bustillo 45b16598e3 Revert "Add copyright notice"
This reverts commit 134bf27955e6caab0f7cc731f72551daae6f2a17.
2024-11-30 10:44:22 +01:00

22 lines
597 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." }
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