404labfr / laravel-impersonate

Laravel Impersonate is a plugin that allows you to authenticate as your users.
https://marceau.casals.fr
2k stars 202 forks source link

Login as user with admin authorization #138

Closed ErenYeager80 closed 3 years ago

ErenYeager80 commented 3 years ago

Hi, Can I impersonate a user that is not admin but when that impersonated had admin authorization?

drbyte commented 3 years ago

You can impersonate whoever passes the rules you define in your canImpersonate() function. You can further refine it by adding restrictions in your canBeImpersonated() function. https://github.com/404labfr/laravel-impersonate#advanced-usage

ErenYeager80 commented 3 years ago

Thanks, but this is not my mean. For example X is a customer, I want impersonate X, but when I Impersonated X, X has admin authorizations not customer authorizations

drbyte commented 3 years ago

Do you mean that you want to give admin rights to the customer while impersonating?

To do that, maybe you could check isImpersonating and add additional privileges if appropriate.

matiazar commented 3 years ago

Hi! How can I use that function.. Im administrator, I now impersonated a X user... but I need to know if Im a user or an administrator.

How can i check that? Auth::user()->isImpersonating() gives me an error

Call to undefined method App\Models\User::getImpersonatorId()

thanks!