Skip to content

Commit cb586b9

Browse files
committed
TASK: make it possible to redirect to an url provided by a get param
You can use this to forward to the referrer of the login form
1 parent 080842b commit cb586b9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Classes/Domain/Service/Neos/NeosRedirectTargetService.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public function onAuthenticationSuccess(ControllerContext $controllerContext, Ac
5454
// Neos only logic (configuration at node or via TS)
5555
/** @var ActionRequest $actionRequest */
5656
$actionRequest = $controllerContext->getRequest();
57-
if ($actionRequest->getInternalArgument('__redirectAfterLogin')) {
57+
58+
if ($actionRequest->getHttpRequest()->hasArgument('forwardUrl')) {
59+
return $this->sanitizeForwardUrl($actionRequest->getHttpRequest()->getArgument('forwardUrl'));
60+
} elseif ($actionRequest->getInternalArgument('__redirectAfterLogin')) {
5861
return $this->getNodeLinkingService()
5962
->createNodeUri($controllerContext, $actionRequest->getInternalArgument('__redirectAfterLogin'));
6063
}
@@ -98,4 +101,12 @@ protected function getNodeLinkingService()
98101
{
99102
return $this->objectManager->get(LinkingService::class);
100103
}
104+
105+
/**
106+
* @param string $forwardUrl
107+
* @return string
108+
*/
109+
protected function sanitizeForwardUrl(string $forwardUrl): string {
110+
return filter_var($forwardUrl, FILTER_SANITIZE_URL);
111+
}
101112
}

0 commit comments

Comments
 (0)