allow to edit username (#4559)

This commit is contained in:
Kevin Papst
2024-01-14 13:02:44 +01:00
committed by GitHub
parent 5acd33dd64
commit fdda9841fa
6 changed files with 43 additions and 2 deletions

View File

@@ -309,15 +309,18 @@ final class ProfileController extends AbstractController
private function createEditForm(User $user): FormInterface
{
$currentUser = $this->getUser();
return $this->createForm(
UserEditType::class,
$user,
[
'action' => $this->generateUrl('user_profile_edit', ['username' => $user->getUserIdentifier()]),
'method' => 'POST',
'include_active_flag' => ($user->getId() !== $this->getUser()->getId()),
'include_active_flag' => $user !== $currentUser,
'include_preferences' => true,
'include_supervisor' => $this->isGranted('supervisor', $user),
'include_username' => $currentUser->isSuperAdmin() && $currentUser !== $user,
'include_password_reset' => $this->isGranted('password', $user),
]
);

View File

@@ -42,6 +42,14 @@ class UserEditType extends AbstractType
$user = $options['data'];
}
if ($options['include_username']) {
$builder->add('username', TextType::class, [
'label' => 'user_identifier',
'help' => 'user_identifier.help',
'required' => true,
]);
}
$builder->add('alias', TextType::class, [
'label' => 'alias',
'required' => false,
@@ -117,6 +125,7 @@ class UserEditType extends AbstractType
'include_active_flag' => true,
'include_preferences' => true,
'include_supervisor' => true,
'include_username' => false,
'include_password_reset' => true,
]);
}