2026-01-12 15:52:27 +01:00
|
|
|
class SessionsController < ApplicationController
|
|
|
|
|
allow_unauthenticated_access only: %i[ new create ]
|
2026-09-29 07:35:53 +02:00
|
|
|
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
|
2026-09-29 07:35:53 +02:00
|
|
|
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
|