OctopyID / LaraPersonate

Login as a different user quickly for Laravel
MIT License
295 stars 27 forks source link

Call to undefined method Octopy\Impersonate\Impersonate::isInImpersonation() #25

Open MCKLtech opened 1 week ago

MCKLtech commented 1 week ago

Describe the bug

It seems app() and impersonate() are not registered/working e.g.

app('impersonate')->isInImpersonation()

and

impersonate()

Do not appear to be working as they will throw an error such as: Call to undefined method Octopy\Impersonate\Impersonate::isInImpersonation()

But the following does work:

auth()->user()->impersonate($user);
SupianIDz commented 1 week ago

Hi @MCKLtech, there is no unction isInImpersonation. If you want to check whether you are in impersonation mode or not, you can use this code:

impersonate()->check();

// or
app('impersonate')->check();

// or
$user->impersonate()->check();

Will return the value true when in impersonation mode.