feat: custom hx redirect class
This commit is contained in:
@@ -8,6 +8,7 @@ use App\BusProNet\ApiClient;
|
||||
use App\BusProNet\Exception\ApiClientException;
|
||||
use App\BusProNet\Model\PersonalData;
|
||||
use App\Entity\User;
|
||||
use App\Htmx\HxRedirectResponse;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
@@ -119,10 +120,15 @@ class BpnAuthenticator extends AbstractLoginFormAuthenticator implements Authent
|
||||
'email' => $token->getUserIdentifier(),
|
||||
]);
|
||||
|
||||
if ($targetPath = $this->getTargetPath($request->getSession(), $firewallName)) {
|
||||
return new RedirectResponse($targetPath);
|
||||
$targetPath = $this->getTargetPath($request->getSession(), $firewallName)
|
||||
?? $this->urlGenerator->generate('app_account');
|
||||
|
||||
// When redirecting to admin from an HTMX request, force a full page navigation
|
||||
// to avoid layout issues between frontend (hx-boost) and EasyAdmin
|
||||
if ($request->headers->has('HX-Request') && str_contains($targetPath, '/admin')) {
|
||||
return new HxRedirectResponse($targetPath);
|
||||
}
|
||||
|
||||
return new RedirectResponse($this->urlGenerator->generate('app_account'));
|
||||
return new RedirectResponse($targetPath);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user