Skip to content

Commit

Permalink
Remove base dir from redirect urls
Browse files Browse the repository at this point in the history
Align the redirect parameter with the implementation in authentication.
Having the base path present results in a double base path.

See cakephp/authentication#343
  • Loading branch information
markstory committed Jan 25, 2020
1 parent f19d3e0 commit 059ecda
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 10 deletions.
4 changes: 0 additions & 4 deletions src/Middleware/UnauthorizedHandler/CakeRedirectHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ protected function getUrl(ServerRequestInterface $request, array $options)
$url = $options['url'];
if ($options['queryParam'] !== null) {
$uri = $request->getUri();
/** @psalm-suppress NoInterfaceProperties */
if (property_exists($uri, 'base')) {
$uri = $uri->withPath($uri->base . $uri->getPath());
}
$redirect = $uri->getPath();
if ($uri->getQuery()) {
$redirect .= '?' . $uri->getQuery();
Expand Down
4 changes: 0 additions & 4 deletions src/Middleware/UnauthorizedHandler/RedirectHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ protected function getUrl(ServerRequestInterface $request, array $options)
$url = $options['url'];
if ($options['queryParam'] !== null && $request->getMethod() === 'GET') {
$uri = $request->getUri();
/** @psalm-suppress NoInterfaceProperties */
if (property_exists($uri, 'base')) {
$uri = $uri->withPath($uri->base . $uri->getPath());
}
$redirect = $uri->getPath();
if ($uri->getQuery()) {
$redirect .= '?' . $uri->getQuery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function testHandleRedirectWithBasePath()

$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals(
'/basedir/login?redirect=%2Fbasedir%2Fadmin%2Fdashboard',
'/basedir/login?redirect=%2Fadmin%2Fdashboard',
$response->getHeaderLine('Location')
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function testHandleRedirectWithBasePath()

$this->assertEquals(302, $response->getStatusCode());
$this->assertEquals(
'/basedir/login?redirect=%2Fbasedir%2Fpath',
'/basedir/login?redirect=%2Fpath',
$response->getHeaderLine('Location')
);
}
Expand Down

0 comments on commit 059ecda

Please sign in to comment.