chore: remove the seed command and the dev login

This commit is contained in:
fromme committed 2026-09-17 17:55:58 +02:00
1 parent 376251b6d6
commit dc1822b8cf
7 files changed
-320

No files matched your search

-68
View File
@@ -1,68 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Security;
use App\Repository\UserRepository;
use Symfony\Component\DependencyInjection\Attribute\When;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
/**
* Logs in whoever was picked on /dev/login, with no credentials at all.
*
* Dev only. It deliberately has the same shape the real OAuth2 authenticator will take in plan
* step 6 -- supports() matches one route, authenticate() returns a SelfValidatingPassport -- so
* swapping it out is a deletion rather than a rewrite.
*/
#[When('dev')]
final class DevLoginAuthenticator extends AbstractAuthenticator
{
public function __construct(
private readonly UserRepository $users,
private readonly UrlGeneratorInterface $urlGenerator,
) {
}
public function supports(Request $request): bool
{
return 'app_dev_login' === $request->attributes->get('_route') && $request->isMethod('POST');
}
public function authenticate(Request $request): Passport
{
$id = $request->request->getInt('user');
return new SelfValidatingPassport(new UserBadge((string) $id, function (string $identifier) {
$user = $this->users->find((int) $identifier);
if (null === $user) {
throw new CustomUserMessageAuthenticationException('Unbekannter Benutzer.');
}
return $user;
}));
}
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
{
return new RedirectResponse($this->urlGenerator->generate('app_dashboard'));
}
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response
{
$request->getSession()->getFlashBag()->add('error', $exception->getMessageKey());
return new RedirectResponse($this->urlGenerator->generate('app_dev_login'));
}
}