404labfr / 404labfr/laravel-impersonate

Custom App SessionGuard breaks this plugin

Offen
#84 2 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
help wanted
Vorherrschende Sprache
PHP
Sterne
2.3k
Forks
235
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hello,

I tried to use your plugin but I couldn't for the life of me figure out why it wouldn't work... both the impersonate.take and the impersonate.leave routes wouldn't do anything useful.

I've then dumped the `Session::all()` and noticed something was actually happening but I still wasn't logged in with the user i wanted to impersonate.

So I've dug deeper and reached your `ImpersonateManager` class. Your functions `take` and `leave` are wrapped in `try {} catch {}` so i just removed the wrapper and got exceptions that `quietLogin` and `quietLogout` didn't exist in my app `SessionGuard`.

That's when I've figured it out that your manager was using my custom SessionGuard instead of your own `\Lab404\Impersonate\Guard\SessionGuard`. Having my own SessionGuard class extend yours instead of the base class fixed this issue right away.

... HOWEVER ...

Why on earth did you put the try catch wrapper and then DISCARD all possible errors / exceptions thrown? I'm talking about [this](https://github.com/404labfr/laravel-impersonate/blob/master/src/Services/ImpersonateManager.php#L120) and [this](https://github.com/404labfr/laravel-impersonate/blob/master/src/Services/ImpersonateManager.php#L146)

Also please specify in the readme that your plugin needs to use your own SessionGuard. Using a custom SessionGuard instead of your own will never work and unfortunately it will never throw any errors 😞

The solution of course is to have the custom SessionGuard extend your SessionGuard which includes the `quiet` functions...

There has to be a better way of doing this...
Thanks!

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.