src/Controller/ResettingController.php line 45

Open in your IDE?
  1. <?php
  2. // src/Controller/RegistrationController.php
  3. namespace App\Controller;
  4. use App\Entity\AppUser;
  5. use App\Form\RegistrationFormType;
  6. use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  11. use Symfony\Component\HttpFoundation\Request;
  12. /**
  13.  * @Route("/{_locale}/resetting")
  14.  */
  15. class ResettingController extends AbstractController
  16. {
  17.     
  18.     /**
  19.      * @Route("/request", name="resetting.request")
  20.      * @return \Symfony\Component\HttpFoundation\Response
  21.     */
  22.     public function request(Request $requestUserPasswordHasherInterface $passwordHasher)
  23.     {
  24.         // ... e.g. get the user data from a registration form
  25.         $user = new AppUser;
  26.         $plaintextPassword '';
  27.         
  28.         $form $this->createForm(RegistrationFormType::class, $user);
  29.         if($request->getMethod() == 'POST'){
  30.              $form->handleRequest($request);
  31.             if($form->isValid()){
  32.                 $data $form->getData();
  33.                     
  34.                 $plaintextPassword '';
  35.                 // hash the password (based on the security.yaml config for the $user class)
  36.                 $hashedPassword $passwordHasher->hashPassword($user$data->getPlainPassword());
  37.                 $user->setPassword($hashedPassword);
  38.             }
  39.         }
  40.         
  41.         return $this->render('resetting/request.html.twig', [ 
  42.         ]);
  43.     }
  44. }