mirror of
https://github.com/resources-manager/resources-manager-webui.git
synced 2024-11-21 23:49:19 +01:00
can register user now
This commit is contained in:
parent
4e4ae007c4
commit
c311f3a88e
|
@ -21,4 +21,4 @@ register:
|
||||||
users:
|
users:
|
||||||
path: /users
|
path: /users
|
||||||
controller: App\Controller\SecurityController::showUserManagePage
|
controller: App\Controller\SecurityController::showUserManagePage
|
||||||
methods: GET
|
methods: GET|POST
|
|
@ -112,16 +112,43 @@ class SecurityController extends AbstractController
|
||||||
->add('save', SubmitType::class,[])
|
->add('save', SubmitType::class,[])
|
||||||
->getForm();
|
->getForm();
|
||||||
}
|
}
|
||||||
public function showUserManagePage()
|
|
||||||
|
public function showUserManagePage(Request $request, UserPasswordEncoderInterface $passwordEncoder)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$formCreateUser = $this->getformCreateUser();
|
||||||
|
$formCreateUser->handleRequest($request);
|
||||||
|
|
||||||
|
if ($formCreateUser->isSubmitted() && $formCreateUser->isValid()) {
|
||||||
|
$userValues = $formCreateUser->getData();
|
||||||
|
|
||||||
|
$user = new User();
|
||||||
|
$user ->setEmail($userValues ["email"])
|
||||||
|
->setPassword( $passwordEncoder->encodePassword($user,$userValues ["password"]) )
|
||||||
|
->setDisplayName( $userValues ["display_name"] )
|
||||||
|
->setActive(true)
|
||||||
|
->setRoles(array( $userValues["roles"] ));
|
||||||
|
|
||||||
|
$entityManager = $this->getDoctrine()->getManager();
|
||||||
|
$entityManager->persist($user);
|
||||||
|
$entityManager->flush();
|
||||||
|
|
||||||
|
//empty the form
|
||||||
|
$formCreateUser = $this->getformCreateUser();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$users = $this->getDoctrine()
|
$users = $this->getDoctrine()
|
||||||
->getRepository(User::class)
|
->getRepository(User::class)
|
||||||
->findAll();
|
->findAll();
|
||||||
$menus = new Menus();
|
$menus = new Menus();
|
||||||
|
|
||||||
|
|
||||||
return $this->render('security/listUsers.html.twig', [
|
return $this->render('security/listUsers.html.twig', [
|
||||||
"menus" => $menus->getMenus( $this->getUser() ),
|
"menus" => $menus->getMenus( $this->getUser() ),
|
||||||
"users" => $users,
|
"users" => $users,
|
||||||
"formCreateUser" => $this->getformCreateUser()->createView()
|
"formCreateUser" => $formCreateUser->createView()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<article id="FormCreateUser">
|
<article id="FormCreateUser">
|
||||||
<h2>Create a new user</h2>
|
<h2>Create a new user</h2>
|
||||||
{{ form(formCreateUser) }}
|
{{ form(formCreateUser) }}
|
||||||
|
<p>{{ form_errors(formCreateUser) }}</p>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user