-
Notifications
You must be signed in to change notification settings - Fork 209
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
Package seems not to work with Sanctum / Laravel 9? #156
Comments
Hello! This is still revelant? Can you give more info? |
I have similar case but mine always back to login menu when I click impersonate. I use this script in livewire component: public function impersonate(User $user) and wire:click="impersonate({{ $user->id }}) in the button. I have another webs impersonate using same laravel but use breeze and it can work as expected. |
@jonathanoeijoeng That does sound like #162, you can check if the workaround described there works until a fix is available |
Hi. Thanks so much for the reply. |
I did put it in a new folder |
So we put in new file? What is the name file? |
That depends on you're naming convention, if you follow the default it should be |
just did as instructed but still logged out after click impersonate button
…On Tue, Jul 26, 2022 at 4:10 PM Arne_ ***@***.***> wrote:
That depends on you're naming convention, if you follow the default it
should be SessionGuard.php
—
Reply to this email directly, view it on GitHub
<#156 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABVYLICRSQGG24KRAWCKAY3VV6TRBANCNFSM5SU7736A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I am also having the issue that once you try to impersonate you're just logged out. What is the official solution to this issue? |
I have the identical issue. Have you found a solution? |
@tpharaoh Does the Workaround in #162 (comment) work for you? |
I was able to impersonate after delete config('jetstream.auth_session'), in web route. I dont kmow whether it has impact to security or not. |
I ended up just switching out the auth middleware from sanctum to web: Route::middleware(['auth:sanctum',]) This worked for me. |
Having this issue with a fresh install of Laravel + Jetstream. Sent to login screen after impersonation |
I am using a different library because this happened to me too, unfortunately I got the same problem there, but I found a solution. And I think it will probably work here too. $result = auth()->user()?->impersonate($user);
Auth::guard('sanctum')->setUser($result);
for leaving impersonation, I did this: $impersonate = Auth::user()?->impersonate();
$user = $impersonate->getImpersonator();
$impersonate->leave();
Auth::guard('sanctum')->setUser($user); |
Hi Henrique, Unfortunately I wasn't able to get your fix working, but thanks for the suggestion. |
I was able to make it work by using @henriquecm answer. But instead of
I used
because setUser() does not accept a bool $result but a user. |
I'm confused - there seems to be a few ways for getting this to work with Jetstream - which way is the recommended approach as I also don't seem to be able to get this working with Jetstream (but works fine on my other site that is using Laravel 11.x and Breeze) |
I eventually gave up with this and switched to use https://github.com/OctopyID/LaraPersonate which I was able to get working well in Jetstream |
Hi there guys,
I have some really weird issue implementing this package in a project of mine. This is weird, since I have two other projects with this package working.
The error I am receiving when installing this package is:
I have done some digging and found out that the
sanctum
driver is missing in thecustomCreators
property ofAuthManager
. When I disable theImpersonateServiceProvider::registerAuthDriver
method, my tests run perfectly, but impersonation doesn't work. I see that thesanctum
driver is visible in thecustomCreators
property ofAuthManager
.I am not a specialist in the authentication system of Laravel, so I don't have any clue why this is happening.
Do you have any direction for me to dig further?
Regards, Bob
The text was updated successfully, but these errors were encountered: