Skip to content

Commit 059ecda

Browse files
committed
Remove base dir from redirect urls
Align the redirect parameter with the implementation in authentication. Having the base path present results in a double base path. See cakephp/authentication#343
1 parent f19d3e0 commit 059ecda

File tree

4 files changed

+2
-10
lines changed

4 files changed

+2
-10
lines changed

src/Middleware/UnauthorizedHandler/CakeRedirectHandler.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ protected function getUrl(ServerRequestInterface $request, array $options)
6565
$url = $options['url'];
6666
if ($options['queryParam'] !== null) {
6767
$uri = $request->getUri();
68-
/** @psalm-suppress NoInterfaceProperties */
69-
if (property_exists($uri, 'base')) {
70-
$uri = $uri->withPath($uri->base . $uri->getPath());
71-
}
7268
$redirect = $uri->getPath();
7369
if ($uri->getQuery()) {
7470
$redirect .= '?' . $uri->getQuery();

src/Middleware/UnauthorizedHandler/RedirectHandler.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ protected function getUrl(ServerRequestInterface $request, array $options)
9494
$url = $options['url'];
9595
if ($options['queryParam'] !== null && $request->getMethod() === 'GET') {
9696
$uri = $request->getUri();
97-
/** @psalm-suppress NoInterfaceProperties */
98-
if (property_exists($uri, 'base')) {
99-
$uri = $uri->withPath($uri->base . $uri->getPath());
100-
}
10197
$redirect = $uri->getPath();
10298
if ($uri->getQuery()) {
10399
$redirect .= '?' . $uri->getQuery();

tests/TestCase/Middleware/UnauthorizedHandler/CakeRedirectHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function testHandleRedirectWithBasePath()
149149

150150
$this->assertEquals(302, $response->getStatusCode());
151151
$this->assertEquals(
152-
'/basedir/login?redirect=%2Fbasedir%2Fadmin%2Fdashboard',
152+
'/basedir/login?redirect=%2Fadmin%2Fdashboard',
153153
$response->getHeaderLine('Location')
154154
);
155155
}

tests/TestCase/Middleware/UnauthorizedHandler/RedirectHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function testHandleRedirectWithBasePath()
150150

151151
$this->assertEquals(302, $response->getStatusCode());
152152
$this->assertEquals(
153-
'/basedir/login?redirect=%2Fbasedir%2Fpath',
153+
'/basedir/login?redirect=%2Fpath',
154154
$response->getHeaderLine('Location')
155155
);
156156
}

0 commit comments

Comments
 (0)