Skip to content

Commit

Permalink
Merge pull request #1880 from tomudding/fix/exploding-login-redirects
Browse files Browse the repository at this point in the history
fix: exploding login redirect links
  • Loading branch information
tomudding authored Jul 31, 2024
2 parents 98ec005 + cc15691 commit cc42f4a
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions module/Application/view/partial/main-nav.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ endif; ?>
</li>
<?php
if (null === $this->identity() && null === $this->companyIdentity()): ?>
<?php
// Do NOT include the `redirect_to` parameter if it is already included (i.e. we are already on the
// login page).
$currentUrl = $this->serverUrl(true);
$redirectTo = base64_encode($currentUrl);
$loginUrl = $this->url(
name: 'user/login',
reuseMatchedParams: true,
);

if (!str_contains($currentUrl, 'redirect_to')) {
$loginUrl = $this->url(
name: 'user/login',
options: ['query' => ['redirect_to' => base64_encode($this->serverUrl(true))]],
reuseMatchedParams: true,
);
}
?>
<li class="dropdown pull-right">
<a href="<?= $this->hashUrl() ?>" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">
Expand All @@ -102,10 +120,7 @@ endif; ?>
</a>
<ul class="dropdown-menu">
<li>
<a href="<?= $this->url(
name: 'user/login',
options: ['query' => ['redirect_to' => base64_encode($this->serverUrl(true))]],
) ?>">
<a href="<?= $loginUrl ?>">
<?= $this->translate('Login') ?>
</a>
</li>
Expand Down

0 comments on commit cc42f4a

Please sign in to comment.