Skip to content
Snippets Groups Projects
Commit 2522a9c4 authored by Benni Mack's avatar Benni Mack
Browse files

[BUGFIX] Allow to modify redirectUrl via PSR-14 event in EXT:felogin

The "BeforeRedirectEvent" in EXT:felogin did not
allow to modify the actual redirectUrl,
which is now modified, as the Event was not
as powerful.

Resolves: #96813
Releases: main, 11.5
Change-Id: I5716c9a3f8d58cd019dca5e3e9d47a242c9ec45e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78135


Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: default avatarOliver Bartsch <bo@cedev.de>
Tested-by: default avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: default avatarGeorg Ringer <georg.ringer@gmail.com>
parent 582b23ad
Branches
Tags
No related merge requests found
...@@ -193,8 +193,11 @@ class LoginController extends AbstractLoginFormController ...@@ -193,8 +193,11 @@ class LoginController extends AbstractLoginFormController
protected function handleRedirect(): ?ResponseInterface protected function handleRedirect(): ?ResponseInterface
{ {
if ($this->redirectUrl !== '') { if ($this->redirectUrl !== '') {
$this->eventDispatcher->dispatch(new BeforeRedirectEvent($this->loginType, $this->redirectUrl)); $event = new BeforeRedirectEvent($this->loginType, $this->redirectUrl, $this->request);
return $this->redirectToUri($this->redirectUrl); $this->eventDispatcher->dispatch($event);
if ($event->getRedirectUrl() !== '') {
return $this->redirectToUri($event->getRedirectUrl());
}
} }
return null; return null;
} }
......
...@@ -17,14 +17,19 @@ declare(strict_types=1); ...@@ -17,14 +17,19 @@ declare(strict_types=1);
namespace TYPO3\CMS\FrontendLogin\Event; namespace TYPO3\CMS\FrontendLogin\Event;
use Psr\Http\Message\ServerRequestInterface;
/** /**
* Notification before a redirect is made. * Notification before a redirect is made, which also allows to modify
* the actual redirect URL. Setting the redirect to an empty string
* will avoid triggering a redirect.
*/ */
final class BeforeRedirectEvent final class BeforeRedirectEvent
{ {
public function __construct( public function __construct(
private readonly string $loginType, private readonly string $loginType,
private readonly string $redirectUrl private string $redirectUrl,
private readonly ServerRequestInterface $request,
) { ) {
} }
...@@ -37,4 +42,14 @@ final class BeforeRedirectEvent ...@@ -37,4 +42,14 @@ final class BeforeRedirectEvent
{ {
return $this->redirectUrl; return $this->redirectUrl;
} }
public function setRedirectUrl(string $redirectUrl): void
{
$this->redirectUrl = $redirectUrl;
}
public function getRequest(): ServerRequestInterface
{
return $this->request;
}
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment