Skip to content
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

Impersonation breaks down when calling the route('impersonate', $id) in vue #166

Open
luigibriganti opened this issue Aug 26, 2022 · 2 comments

Comments

@luigibriganti
Copy link

Hi,
I have a Laravel project that runs on Inertia/Jetstream + Vue and I installed impersonate following the procedure, but maybe I missed something.

I followed the Simple usage guidelines, creating a get route in web.php like this:

Route::get('/impersonate/{id}', function($id){ Auth::user()->impersonate($id); })->name('impersonate');

But when I call it I get this error:
Schermata del 2022-08-26 09-41-33

Following the Using the built-in controller guidelines, instead, I get the following error in console:

Schermata del 2022-08-26 09-43-19

this one is get calling route('impersonate', user.id) in my vue template.

Did I miss something or am I doing something wrong? Thanks.

@raducostinean
Copy link

I might be wrong, but you need to pass a model instead of ID.
Try using route model binding and see if it works:
Route::get('/impersonate/{user}', function(User $user){ Auth::user()->impersonate($user); })->name('impersonate');

@mgkimsal
Copy link

@luigibriganti your ziggy config might be limiting what routes are sent down. I hit that recently. check config/ziggy.php

Also, did you add Route::impersonate() to your web routes?

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

No branches or pull requests

3 participants