mirror of
https://github.com/resources-manager/resources-manager-webui.git
synced 2024-11-21 07:29:20 +01:00
can register user now
This commit is contained in:
parent
4e4ae007c4
commit
c311f3a88e
|
@ -21,4 +21,4 @@ register:
|
|||
users:
|
||||
path: /users
|
||||
controller: App\Controller\SecurityController::showUserManagePage
|
||||
methods: GET
|
||||
methods: GET|POST
|
|
@ -112,16 +112,43 @@ class SecurityController extends AbstractController
|
|||
->add('save', SubmitType::class,[])
|
||||
->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()
|
||||
->getRepository(User::class)
|
||||
->findAll();
|
||||
$menus = new Menus();
|
||||
|
||||
|
||||
return $this->render('security/listUsers.html.twig', [
|
||||
"menus" => $menus->getMenus( $this->getUser() ),
|
||||
"users" => $users,
|
||||
"formCreateUser" => $this->getformCreateUser()->createView()
|
||||
"formCreateUser" => $formCreateUser->createView()
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<article id="FormCreateUser">
|
||||
<h2>Create a new user</h2>
|
||||
{{ form(formCreateUser) }}
|
||||
<p>{{ form_errors(formCreateUser) }}</p>
|
||||
</article>
|
||||
|
||||
<article>
|
||||
|
|
Loading…
Reference in New Issue
Block a user