Skip to content

Commit

Permalink
Ensure middleware and reverse ui uses the correct guard when dealing …
Browse files Browse the repository at this point in the history
…with multiple guard impersonation
  • Loading branch information
Sam D Harris committed Nov 12, 2021
1 parent 5e1163e commit 03f3d4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions resources/views/reverse.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"
>
<p>
@if( auth()->user()->name )
{{ __('Impersonating as') }} {{ auth()->user()->name }}
@if( auth($impersonatorGuardName)->user()->name )
{{ __('Impersonating as') }} {{ auth($impersonatorGuardName)->user()->name }}
@endif
</p>

Expand Down
8 changes: 5 additions & 3 deletions src/Http/Middleware/Impersonate.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public function handle($request, $next)
$response = $next($request);

$manager = app('impersonate');

$impersonatorGuardName = $manager->getImpersonatorGuardUsingName();
if (
$manager->isImpersonating() &&

auth()->check() &&
auth($impersonatorGuardName)->check() &&

! ($response instanceof RedirectResponse) &&

Expand All @@ -47,7 +47,9 @@ public function handle($request, $next)
/** @var Response $response * */
$content = $response->getContent();

$content .= view('nova-impersonate::reverse')->render();
$content .= view('nova-impersonate::reverse', [
'impersonatorGuardName' => $impersonatorGuardName,
])->render();

$response->setContent($content);
}
Expand Down

0 comments on commit 03f3d4e

Please sign in to comment.