From 26c8da8b69b8dced7abb1639b2c48575834e3f70 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Thu, 6 Sep 2018 18:57:23 +0200 Subject: [PATCH] Implemented basic login process --- application/src/Controller/UserController.php | 19 ++++++++++++++++--- .../Controller/UserControllerInterface.php | 3 ++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/application/src/Controller/UserController.php b/application/src/Controller/UserController.php index 15661ac..065f906 100644 --- a/application/src/Controller/UserController.php +++ b/application/src/Controller/UserController.php @@ -9,6 +9,7 @@ use App\Entity\User; use Symfony\Component\Form\Extension\Core\Type\PasswordType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\HttpFoundation\Request; /** * @@ -31,14 +32,26 @@ class UserController extends AbstractController implements UserControllerInterfa * * @Route("/user/register", name="user_register") */ - public function register(): Response + public function register(Request $request): Response { $user = new User(); $form = $this->createFormBuilder($user) ->add('username', TextType::class) ->add('password', PasswordType::class) - ->add('save', SubmitType::class,['label' => 'register']) + ->add('save', SubmitType::class, [ + 'label' => 'register' + ]) ->getForm(); - return $this->render("user/register.html.twig",['form'=>$form->createView()]); + $form->handleRequest($request); + if ($form->isSubmitted() && $form->isValid()) { + + $task = $form->getData(); + $entityManager = $this->getDoctrine()->getManager(); + $entityManager->persist($task); + $entityManager->flush(); + } + return $this->render("user/register.html.twig", [ + 'form' => $form->createView() + ]); } } \ No newline at end of file diff --git a/application/src/Controller/UserControllerInterface.php b/application/src/Controller/UserControllerInterface.php index d285b2f..2b96299 100644 --- a/application/src/Controller/UserControllerInterface.php +++ b/application/src/Controller/UserControllerInterface.php @@ -3,6 +3,7 @@ namespace App\Controller; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; +use Symfony\Component\HttpFoundation\Request; /** * @@ -13,5 +14,5 @@ interface UserControllerInterface { public function logout():Response; - public function register():Response; + public function register(Request $request):Response; }