Skip to content

Commit 77d847a

Browse files
Add impersonate action
1 parent 5a1a504 commit 77d847a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Controller/Admin/UserCrudController.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
3232
use Symfony\Component\HttpFoundation\Response;
3333
use Symfony\Component\PasswordHasher\Hasher\Pbkdf2PasswordHasher;
34+
use Symfony\Component\Routing\Generator\UrlGenerator;
3435
use Symfony\Component\Security\Http\Attribute\IsGranted;
3536
use Symfony\Contracts\Translation\TranslatorInterface;
3637

@@ -106,7 +107,10 @@ public function configureActions(Actions $actions): Actions
106107
->addCssClass('text-warning'))->update(Crud::PAGE_INDEX, Action::DELETE, fn (Action $action) => $action->setIcon('fa fa-trash-o')
107108
->setLabel(false)
108109
->addCssClass(''))->update(Crud::PAGE_INDEX, Action::BATCH_DELETE, fn (Action $action) => $action->setLabel('Delete')
109-
->addCssClass(''))->add(Crud::PAGE_EDIT, Action::new('generateToken')->linkToCrudAction('generateToken'));
110+
->addCssClass(''))->add(Crud::PAGE_EDIT, Action::new('generateToken')->linkToCrudAction('generateToken'))
111+
->add(Crud::PAGE_INDEX, Action::new('ConnectAs')->linkToUrl(function (User $user) {
112+
return $this->generateUrl('process', ['_switch_user' => $user->getEmail()], UrlGenerator::ABSOLUTE_URL);
113+
})->setLabel(false)->setIcon('fa-solid fa-right-to-bracket'))->setPermission('ConnectAs', 'ROLE_SUPER_ADMIN');
110114
}
111115

112116
public function generateToken(AdminContext $adminContext, AdminUrlGenerator $adminUrlGenerator): Response

src/DependencyInjection/CleverAgeUiProcessExtension.php

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ public function prepend(ContainerBuilder $container): void
150150
'target' => 'process_login',
151151
'clear_site_data' => '*',
152152
],
153+
'switch_user' => true,
153154
],
154155
],
155156
]

0 commit comments

Comments
 (0)