Skip to content

Commit

Permalink
Set Redirect in the Session for a Dyanmic getLeaveRedirectTo
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjsturge committed Nov 22, 2024
1 parent 82cad73 commit bd4b761
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 bd4b761

Please sign in to comment.