mirror of
https://github.com/archtechx/tenancy.git
synced 2026-05-07 01:04:03 +00:00
Make stopImpersonating throw an exception if no user is impersonated currently
This commit is contained in:
parent
1289550533
commit
d17c7b3e86
2 changed files with 13 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ use Stancl\Tenancy\Contracts\Feature;
|
|||
use Stancl\Tenancy\Contracts\Tenant;
|
||||
use Stancl\Tenancy\Database\Models\ImpersonationToken;
|
||||
use Stancl\Tenancy\Tenancy;
|
||||
use Exception;
|
||||
|
||||
class UserImpersonation implements Feature
|
||||
{
|
||||
|
|
@ -84,6 +85,10 @@ class UserImpersonation implements Feature
|
|||
*/
|
||||
public static function stopImpersonating(bool $logout = true): void
|
||||
{
|
||||
if (! static::isImpersonating()) {
|
||||
throw new Exception('Not currently impersonating any user.');
|
||||
}
|
||||
|
||||
if ($logout) {
|
||||
$guard = session()->get('tenancy_impersonation_guard');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue