Skip to content

Commit 6fefa13

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 49bb64b commit 6fefa13

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
@@ -69,10 +69,6 @@ protected function getUrl(ServerRequestInterface $request, array $options): stri
6969
$url = $options['url'];
7070
if ($options['queryParam'] !== null) {
7171
$uri = $request->getUri();
72-
/** @psalm-suppress NoInterfaceProperties */
73-
if (property_exists($uri, 'base')) {
74-
$uri = $uri->withPath($uri->base . $uri->getPath());
75-
}
7672
$redirect = $uri->getPath();
7773
if ($uri->getQuery()) {
7874
$redirect .= '?' . $uri->getQuery();

src/Middleware/UnauthorizedHandler/RedirectHandler.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ protected function getUrl(ServerRequestInterface $request, array $options): stri
101101
$url = $options['url'];
102102
if ($options['queryParam'] !== null && $request->getMethod() === 'GET') {
103103
$uri = $request->getUri();
104-
/** @psalm-suppress NoInterfaceProperties */
105-
if (property_exists($uri, 'base')) {
106-
$uri = $uri->withPath($uri->base . $uri->getPath());
107-
}
108104
$redirect = $uri->getPath();
109105
if ($uri->getQuery()) {
110106
$redirect .= '?' . $uri->getQuery();

tests/TestCase/Middleware/UnauthorizedHandler/CakeRedirectHandlerTest.php

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

146146
$this->assertEquals(302, $response->getStatusCode());
147147
$this->assertEquals(
148-
'/basedir/login?redirect=%2Fbasedir%2Fadmin%2Fdashboard',
148+
'/basedir/login?redirect=%2Fadmin%2Fdashboard',
149149
$response->getHeaderLine('Location')
150150
);
151151
}

tests/TestCase/Middleware/UnauthorizedHandler/RedirectHandlerTest.php

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

147147
$this->assertEquals(302, $response->getStatusCode());
148148
$this->assertEquals(
149-
'/basedir/login?redirect=%2Fbasedir%2Fpath',
149+
'/basedir/login?redirect=%2Fpath',
150150
$response->getHeaderLine('Location')
151151
);
152152
}

0 commit comments

Comments
 (0)