Skip to content

Instantly share code, notes, and snippets.

@dmandrade
Created June 2, 2021 01:01
Show Gist options
  • Save dmandrade/f8d7e16d32a18e250f933e9ca4705b71 to your computer and use it in GitHub Desktop.
Save dmandrade/f8d7e16d32a18e250f933e9ca4705b71 to your computer and use it in GitHub Desktop.
Add password hash in session to fix leave impersonate in Jetstream/Fortify
Add password hash in session to fix leave impersonate in Laravel 8 with jetstream
@package lab404/laravel-impersonate
--- src/Guard/SessionGuard.php
+++ src/Guard/SessionGuard.php
@@ -16,7 +16,9 @@ class SessionGuard extends BaseSessionGuard
public function quietLogin(Authenticatable $user)
{
$this->updateSession($user->getAuthIdentifier());
-
+ $this->session->put([
+ 'password_hash_' . $this->name => $user->getAuthPassword()
+ ]);
$this->setUser($user);
}
@dmandrade
Copy link
Author

dmandrade commented Jun 2, 2021

To apply it automatically just install the vaimo/composer-patches package.

Save this gist file in PROJECT_ROOT/patches folder.

In composer.json add:

    "extra": {
        ...
        "patcher": {
            "search": "patches"
        }
    }

After adding the patch file and update composer.json run composer patch:apply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment