Closed sammyblackbaron closed 1 year ago
@sammyblackbaron you are right! I haven't realized I didn't bumped up the version for Laravel 10. Will do it asap and let you know ;)
@sammyblackbaron done! https://github.com/maurohmartinez/impersonate-users-backpack-laravel/releases/tag/v1.0.12
Thank you so much for doing that so quickly. Unfortunately after setting it up and clicking on "Impersonate" beside a user, I get a 404 saying "The route user/impersonate-user/2 could not be found.".
I have:
Installed via composer
Added the following to my User model:
use MHMartinez\ImpersonateUser\app\Interfaces\ImpersonateInterface; class User extends Authenticatable implements ImpersonateInterface
Added canImpersonateOthers() and canBeImpersonated() to my User model.
Added @include('impersonate_user::exit_impersonated') to my topbar_right_content.blade.php file.
Do I need to call setupImpersonateUserRoutes() to my constructor in my UserCrudController.php?
php artisan routes:list is not showing up the user/impersonate-user/... route.
Sorry to bother you with this!
@sammyblackbaron No worries, we will figure it out. Have you added the operation trait to your UserCrudCrontroller.php? It's the first step.
In UserCrudCrontroller.php, add: 'use \MHMartinez\ImpersonateUser\app\Http\Controllers\Operations\ImpersonateUserOperation;'
That will register the route and take care of the whole operation.
@maurohmartinez - yes I have done that. I copied UserCrudController.php from /vendor/backpack/permissionmanager/src/app/Http/Controllers/UserCrudController.php to /app/Http/Controllers/Admin/UserCrudController.php.
I then altered the top lines of the file to the following:
namespace App\Http\Controllers\Admin;
use Backpack\CRUD\app\Http\Controllers\CrudController;
use Backpack\PermissionManager\app\Http\Requests\UserStoreCrudRequest as StoreRequest;
use Backpack\PermissionManager\app\Http\Requests\UserUpdateCrudRequest as UpdateRequest;
use Illuminate\Support\Facades\Hash;
class UserCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation { store as traitStore; }
use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation { update as traitUpdate; }
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use \MHMartinez\ImpersonateUser\app\Http\Controllers\Operations\ImpersonateUserOperation;
...```
I'm sure I'm doing something wrong but I can't see what! Thank you very much for your help.
My guess is that you now need to also update the Route file so that it actually uses your new UserCrudController
.
For that, you need to copy /vendor/backpack/permissionmanager/src/routes/backpack/permissionmanager.php
into your routes
folder within the same path /vendor/backpack/permissionmanager/src/routes/backpack/
. That way you can now adjust the file so that it actually uses App\Http\Controllers\Admin\UserCrudController
.
Hope that make sense!
Thanks, I've done that but now get this error when clicking on "Impersonate". Sorry for the hassle.
Hmmm... never hit that error. Maybe run php artisan optimize:clear
and see if that fixes the issue?
I ran php artisan optimize:clear
and it still gives the same error. I feel bad for taking up your time - I will try to work out what's going wrong...
@sammyblackbaron no worries! Let me know if you find the error, maybe something has to be updated on the repo!
I'm currently facing issues regarding this. I've followed the steps, however I do not see anything in my routes list as well as I do not see any UI changes (like a button next to the user to impersonate).
Is there something I'm missing? (Using Backpack v6, Laravel v.10)
I'm currently facing issues regarding this. I've followed the steps, however I do not see anything in my routes list as well as I do not see any UI changes (like a button next to the user to impersonate).
Is there something I'm missing? (Using Backpack v6, Laravel v.10)
I haven't had the time to make the changes needed to support Backpack v6. I will try to do it next week!
Thank you so much! I tried to mess around a bit and actually found a way to impersonate a user, however, when I impersonated a user I saw no changes but a button appeared on the section that I had placed it. Clicking it wasn't working though.
I'll postpone the integration then until further notice! :) Thanks!
Hi, any news?
Hi @timoleonn! I tested myself and found a few things to improve, but nothing that should prevent you from implementing this. I have fixed those things and tagged a new release, but in order to help you, let me know a few things:
That will help me understand where it might be the problem.
This is a great addition to other backpack installations I have used in the past but I can't use it on my latest project due to Laravel 10 not being supported. Any chance of it being updated to be compatible?