Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
data
/
web
/
vhosts
/
716cf56cb2.url-de-test.ws
/
htdocs
/
src
/
Controller
/
/srv/data/web/vhosts/716cf56cb2.url-de-test.ws/htdocs/src/Controller/SecurityController.php
<?php namespace App\Controller; use App\Entity\User; use App\Form\RegisterType; use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; class SecurityController extends AbstractController { /** * @Route("/login", name="app_login") */ public function login(AuthenticationUtils $authenticationUtils): Response { // if ($this->getUser()) { // return $this->redirectToRoute('target_path'); // } // get the login error if there is one $error = $authenticationUtils->getLastAuthenticationError(); // last username entered by the user $lastUsername = $authenticationUtils->getLastUsername(); return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]); } /** * @Route("/logout", name="app_logout") */ public function logout(): void { throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.'); } /** * @Route("/register", name="app_register") */ public function register(Request $request, EntityManagerInterface $em, UserPasswordHasherInterface $hasher): Response { $user = new User(); $form = $this->createForm(RegisterType::class, $user); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $hashedPassword = $hasher->hashPassword($user, $user->getPassword()); $user->setCreatedAt(new \DateTimeImmutable()) ->setPassword($hashedPassword); $em->persist($user); $em->flush(); $this->addFlash('success', "Votre inscription à bien été enregistrée"); return $this->redirectToRoute('app_login'); } return $this->render("Front/Pages/register.html.twig", [ 'form' => $form->createView() ]); } }