-
Notifications
You must be signed in to change notification settings - Fork 213
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
Broken with a recent laravel revision? Method Illuminate\Auth\RequestGuard::quietLogin does not exist. #141
Comments
in a working app: current guard returns: Lab404\Impersonate\Guard\SessionGuard in a broken app: current guard returns: Lab404\Impersonate\Guard\SessionGuard So, it seems the second line there, for logging in the new user, returns something else |
@MarceauKa is this project still being actively maintained? |
laravel-impersonate/src/Services/ImpersonateManager.php Lines 114 to 121 in 14de9db
laravel-impersonate/src/Services/ImpersonateManager.php Lines 139 to 140 in 14de9db
public function take($from, $to, $guardName = null)
{
$this->saveAuthCookieInSession();
try {
$currentGuard = $this->getCurrentAuthGuardName();
session()->put($this->getSessionKey(), $from->getAuthIdentifier());
Auth::guard($currentGuard)
->quietLogout();
Auth::guard($guardName ?? $currentGuard)
->quietLogin($to);
Actually, if I'd spent just a bit more time troubleshooting, I'd have found that this error is corrected through a far easier approach by overriding the namespace App\Models;
/* ... */
use Lab404\Impersonate\Services\ImpersonateManager;
/* ... */
public function impersonate(User $user, $guardName = 'web')
{
return app(ImpersonateManager::class)->take($this, $user, $guardName);
} Oh, well. I learned a lot of cool stuff while experimenting. |
Hi thanks for this, I'll merge a fix asap |
@stephancasas this worked for me. Thanks. |
Some error with laravel/sanctum . Overwriting 'impersonate' function with 'web' guard doesn't help....
getCurrentAuthGuardName() always return 'api', and get exception: Method Illuminate\Auth\RequestGuard::quietLogout does not exist. |
Seems there's a breaking change anywhere, since the relevant code swallows the exception, i just get kicked back to the login page...
BadMethodCallException
Method Illuminate\Auth\RequestGuard::quietLogin does not exist.
src/Services/ImpersonateManager.php:121
$this->app['auth']->guard($guardName)->quietLogin($to);
The text was updated successfully, but these errors were encountered: