[4.x] UserImpersonation: store auth guard in session, add $logout param to stopImpersonating()#1437
Draft
[4.x] UserImpersonation: store auth guard in session, add $logout param to stopImpersonating()#1437
$logout param to stopImpersonating()#1437Conversation
…e auth guard in 'tenancy_impersonation_guard' Also make `stopImpersonating()` able to keep the user logged in.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1437 +/- ##
=========================================
Coverage 85.92% 85.93%
- Complexity 1147 1148 +1
=========================================
Files 184 184
Lines 3360 3362 +2
=========================================
+ Hits 2887 2889 +2
Misses 473 473 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The 'tenancy_impersonating' session variable got replaced by 'tenancy_impersonation_guard'.
UserImpersonation::stopImpersonating()now callslogout()on the guard retrieved bysession()->get('tenancy_impersonation_guard')instead of callinglogout()on the current auth guard. Now. if you create the impersonation token with guard 'web', and callUserImpersonation::stopImpersonating(), for example in a route that has theauth:sanctummiddleware (= the current guard in that route would beRequestGuardwhich doesn't even have thelogout()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.Also,
UserImpersonation::stopImpersonating()now accepts the$logoutparameter, which istrueby default. Iffalseis passed, the method doesn't perform the logout.