Aggiunge filtri/colonne (società, orari) e dettaglio leggibile; evita 422 CSRF su logout e non cancella le cover slate custom in sync prod. Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
912 B
Ruby
28 lines
912 B
Ruby
module Admin
|
|
class AuthController < Admin::BaseController
|
|
skip_before_action :require_admin_login, only: %i[new create]
|
|
# Same as public logout: tolerate stale CSRF after long-lived admin tabs.
|
|
skip_before_action :verify_authenticity_token, only: :destroy
|
|
|
|
def new
|
|
redirect_to admin_root_path if admin_logged_in?
|
|
end
|
|
|
|
def create
|
|
account = AdminAccount.find_by(username: params[:username]&.strip)
|
|
if account&.authenticate(params[:password])
|
|
session[:admin_account_id] = account.id
|
|
redirect_to session.delete(:admin_return_to) || admin_root_path, notice: t("admin.flash.login_success")
|
|
else
|
|
flash.now[:alert] = t("admin.flash.invalid_credentials")
|
|
render :new, status: :unauthorized
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
reset_session
|
|
redirect_to admin_login_path, notice: t("admin.flash.logout_success")
|
|
end
|
|
end
|
|
end
|