Skip to content

Commit

Permalink
Merge pull request #210 from adamjsturge/master
Browse files Browse the repository at this point in the history
Set Redirect in the Session for a Dynamic getLeaveRedirectTo
  • Loading branch information
MarceauKa authored Dec 18, 2024
2 parents f3c98b0 + bd4b761 commit f0e7e52
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Services/ImpersonateManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,17 @@ public function getTakeRedirectTo(): string

public function getLeaveRedirectTo(): string
{
$routeName = config('laravel-impersonate.leave_redirect_to');

if (session()->has('laravel-impersonate:leave_redirect_to')) {
$routeName = session('laravel-impersonate:leave_redirect_to');
session()->forget('laravel-impersonate:leave_redirect_to');
}

try {
$uri = route(config('laravel-impersonate.leave_redirect_to'));
$uri = route($routeName);
} catch (\InvalidArgumentException $e) {
$uri = config('laravel-impersonate.leave_redirect_to');
$uri = $routeName;
}

return $uri;
Expand Down

0 comments on commit f0e7e52

Please sign in to comment.