fix: remove redirecting to last url stored in session

This commit is contained in:
Björn Fromme
2024-10-29 08:30:18 +01:00
parent 44af7b4bfa
commit 4fb7f5696f
+3 -10
View File
@@ -21,12 +21,9 @@ use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
use Symfony\Component\Security\Http\Authenticator\Passport\Passport; use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport; use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\Security\Http\Util\TargetPathTrait;
class BpnAuthenticator extends AbstractLoginFormAuthenticator implements AuthenticationEntryPointInterface class BpnAuthenticator extends AbstractLoginFormAuthenticator implements AuthenticationEntryPointInterface
{ {
use TargetPathTrait;
public function __construct( public function __construct(
private readonly UrlGeneratorInterface $urlGenerator, private readonly UrlGeneratorInterface $urlGenerator,
private readonly EntityManagerInterface $entityManager, private readonly EntityManagerInterface $entityManager,
@@ -43,13 +40,13 @@ class BpnAuthenticator extends AbstractLoginFormAuthenticator implements Authent
public function authenticate(Request $request): Passport public function authenticate(Request $request): Passport
{ {
$email = trim($request->request->get('_username', '')); $email = trim($request->request->getString('_username'));
$passwordPlain = trim($request->request->get('_password', '')); $passwordPlain = trim($request->request->getString('_password'));
// Very lame hashing applied here as required by BPN // Very lame hashing applied here as required by BPN
$password = md5($passwordPlain); $password = md5($passwordPlain);
$csrfToken = $request->request->get('_csrf_token', ''); $csrfToken = $request->request->getString('_csrf_token');
return new SelfValidatingPassport( return new SelfValidatingPassport(
new UserBadge($email, function () use ($email, $password, $request) { new UserBadge($email, function () use ($email, $password, $request) {
@@ -90,10 +87,6 @@ class BpnAuthenticator extends AbstractLoginFormAuthenticator implements Authent
$this->entityManager->flush(); $this->entityManager->flush();
if ($targetPath = $this->getTargetPath($request->getSession(), $firewallName)) {
return new RedirectResponse($targetPath);
}
$url = $this->urlGenerator->generate($user->getDefaultRoute()); $url = $this->urlGenerator->generate($user->getDefaultRoute());
return new RedirectResponse($url); return new RedirectResponse($url);