1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 18:04:03 +00:00

Add session state when impersonating tenant (#1029)

* wip

* Fix code style (php-cs-fixer)

* Update TenantUserImpersonationTest.php

* renamed method

* update method name in test

* rename session key

* fix test

* Update src/Features/UserImpersonation.php

Co-authored-by: Samuel Štancl <samuel@archte.ch>

* Update UserImpersonation.php

Co-authored-by: PHP CS Fixer <phpcsfixer@example.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
This commit is contained in:
Abrar Ahmad 2022-12-17 06:08:03 +05:00 committed by GitHub
parent 21dc69e358
commit f42f08cb87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 0 deletions

View file

@ -48,6 +48,23 @@ class UserImpersonation implements Feature
$token->delete();
session()->put('tenancy_impersonating', true);
return redirect($token->redirect_url);
}
public static function isImpersonating(): bool
{
return session()->has('tenancy_impersonating');
}
/**
* Logout from the current domain and forget impersonation session.
*/
public static function leave(): void // todo possibly rename
{
auth()->logout();
session()->forget('tenancy_impersonating');
}
}