-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Would be nice to add an @isImposter blade directive #180
Comments
To clarify: Are you asking for a way to check whether another user is logged-in via impersonation? This package currently only exposes that the current user is logged-in via impersonation. It does that by checking the current user's session for the impersonation keys being present. But there's nothing in this package that allows reaching into another user's session to track whether that person is being impersonated. Something would have to be stored in the database to know that state, and of course to reset it when the person logs out (and also to figure out when that user's session expires even if they didn't click logout). |
Sorry, no I meant just to check if the current user is currently an imposter - as you said, you can find out by checking a session variable. so super tiny problem. maybe it just feels more consistent to me., |
You can use |
I think @BigBlockStudios meant when we have a As a solution, I've did something like this
|
I've done it similarly: //User.php model
/**
* Return true or false whether the user can be impersonated.
* Here we deny impersonation of oneself as that would be pointless.
*/
public function canBeImpersonated(): bool
{
return $this->id != Auth::id();
} @canImpersonate
@canBeImpersonated($user)
<div class="btn-group float-right d-print-none" role="group" aria-label="Impersonate">
<a href="{{ route('impersonate', $user->id) }}"><button type="button" class="btn btn-success text-center"><i class="fa fa-user-circle fa-lg" title="Impersonate this user"></i></button></a>
</div>
@endCanBeImpersonated
@endCanImpersonate |
Would be nice to add an @isImposter() blade directive - checking a session variable for someone impersonating ATM.
The text was updated successfully, but these errors were encountered: