Skip to content

Commit

Permalink
Redirect to previous page after login
Browse files Browse the repository at this point in the history
fixes tastyigniter/TastyIgniter#1064

Signed-off-by: Sam Poyigi <[email protected]>
  • Loading branch information
sampoyigi committed Jan 5, 2024
1 parent 3e5aad1 commit d0e2226
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions components/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public function onRun()
$this->onActivate($code);

$this->prepareVars();

if ($this->page->getId() === $this->property('loginPage'))
$this->setIntendedUrl();
}

public function prepareVars()
Expand Down Expand Up @@ -427,4 +430,12 @@ protected function makeActivationUrl($code)

return $url;
}

protected function setIntendedUrl()
{
$previousUrl = url()->previous();
if (!session()->has('url.intended') && $previousUrl && $previousUrl !== url()->current()) {
session(['url.intended' => $previousUrl]);
}
}
}

0 comments on commit d0e2226

Please sign in to comment.