app.kluk.fr/app/controllers/sessions_controller.rb

22 lines
635 B
Ruby
Raw Normal View History

2026-01-12 15:52:27 +01:00
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: "Trop de tentatives. Réessayez dans quelques minutes." }
2026-01-12 15:52:27 +01:00
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: "Adresse mail ou mot de passe incorrect."
2026-01-12 15:52:27 +01:00
end
end
def destroy
terminate_session
redirect_to new_session_path
end
end