<?php

declare(strict_types=1);

/*
 * This file is part of the Ferienpass package.
 *
 * (c) Richard Henkenjohann <richard@ferienpass.online>
 *
 * For more information visit the project website <https://ferienpass.online>
 * or the documentation under <https://docs.ferienpass.online>.
 */

namespace Ferienpass\CmsBundle\Controller\Fragment;

use Contao\CoreBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
 * Landing page shown when a magic login link fails to authenticate — expired,
 * already used (max_uses), or a stale signature (e.g. the member logged in
 * elsewhere since the link was minted, so `lastLogin` no longer matches).
 *
 * The CMS `login_link` firewall points its `login_path` at the
 * `cms_login_link_invalid` route, which renders this fragment. Without it a
 * failed link fell back to the framework-default `/login` — no such route in
 * the Contao frontend — and dead-ended on a 404.
 *
 * Content is generic on purpose: collapsing every failure reason into one
 * message avoids leaking why a link was rejected.
 */
class LoginLinkInvalid extends AbstractController
{
    public function __invoke(Request $request): Response
    {
        return $this->render('@Contao/fragment/login_link_invalid.html.twig');
    }
}
