1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-05-06 19:44:03 +00:00

Make stopImpersonating throw an exception if no user is impersonated currently

This commit is contained in:
lukinovec 2026-04-13 15:19:17 +02:00
parent 1289550533
commit d17c7b3e86
2 changed files with 13 additions and 0 deletions

View file

@ -234,6 +234,14 @@ test('stopImpersonating logs out the user from tenancy_impersonation_guard store
expect(auth('web')->check())->toBeFalse();
expect(auth('test')->check())->toBeTrue();
expect(UserImpersonation::isImpersonating())->toBeFalse();
// tenancy_impersonation_guard isn't in the session anymore,
// stopImpersonating should throw an exception instead of logging out
expect(fn() => UserImpersonation::stopImpersonating())->toThrow(Exception::class);
expect(auth()->check())->toBeTrue();
});
test('tokens have a limited ttl', function () {