1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-06-21 15:54:04 +00:00
tenancy/src/Features
lukinovec c0fbf6dcbd
[MINOR BC] UserImpersonation: store auth guard in session, add $logout param to stopImpersonating() (#1437)
> Minor breaking change: `session('tenancy_impersonating')` doesn't work
anymore. Use `session('tenancy_impersonation_guard')` instead.

The 'tenancy_impersonating' session variable got replaced by
'tenancy_impersonation_guard'. `UserImpersonation::stopImpersonating()`
now calls `logout()` on the guard retrieved by
`session()->get('tenancy_impersonation_guard')` instead of calling
`logout()` on the _current_ auth guard. Now. if you create the
impersonation token with guard 'web', and call
`UserImpersonation::stopImpersonating()`, for example in a route that
has the `auth:sanctum` middleware (= the current guard in that route
would be `RequestGuard` which doesn't even have the `logout()` method --
not the guard for which the impersonation token was created), the method
will correctly log the user out of the 'web' guard using which he was
actually authenticated instead of the current guard of the visited route
(which doesn't have to be the same guard for which impersonation
started).

`UserImpersonation::stopImpersonating()` now also accepts the `$logout`
parameter, which is `true` by default. If `false` is passed, the method
just forgets `tenancy_impersonation_guard` from session without logging
out.

`UserImpersonation::stopImpersonating()` now throws an exception if
impersonation wasn't active at the point of calling the method.

---------

Co-authored-by: Samuel Stancl <samuel@archte.ch>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-06-05 14:15:19 -07:00
..
CrossDomainRedirect.php Features refactor 2025-08-31 23:18:44 +02:00
DisallowSqliteAttach.php Resolve misc todos, fix phpstan error 2025-10-20 01:57:02 +02:00
TelescopeTags.php Features refactor 2025-08-31 23:18:44 +02:00
TenantConfig.php Add TenantConfigBootstrapper, deprecate Feature implementation 2025-09-26 13:49:15 +02:00
UserImpersonation.php [MINOR BC] UserImpersonation: store auth guard in session, add $logout param to stopImpersonating() (#1437) 2026-06-05 14:15:19 -07:00
ViteBundler.php Features refactor 2025-08-31 23:18:44 +02:00