SHARE
TWEET

Untitled

a guest Oct 21st, 2019 110 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.      * Login
  3.      *
  4.      * @Route("/login", name="account_login")
  5.      *
  6.      * @return Response
  7.      */
  8.     public function login2(AuthenticationUtils $utils, Request $request, ObjectManager $manager, UserPasswordEncoderInterface $encoder)
  9.     {
  10.         // Connexion
  11.         $error = $utils->getLastAuthenticationError();
  12.         $username = $utils->getLastUsername();
  13.  
  14.         // Inscription
  15.         $user = new User();
  16.         $form = $this->createForm(RegistrationType::class, $user);
  17.         $form->handleRequest($request);
  18.  
  19.         if ($form->isSubmitted() && $form->isValid()) {
  20.             $password = $encoder->encodePassword($user, $user->getPassword());
  21.             $user->setHash($password);
  22.             $manager->persist($user);
  23.             $manager->flush();
  24.  
  25.             $this->addFlash(
  26.                 'success',
  27.                 'Votre compte a bien été créé ! Vous pouvez maintenant vous connecter'
  28.             );
  29.  
  30.             $this->redirectToRoute('account_login');
  31.         }
  32.  
  33.  
  34.         return $this->render('security/login.html.twig', [
  35.             'hasError' => $error !== null,
  36.             'username' => $username,
  37.             'form' => $form->createView(),
  38.         ]);
  39.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top