namespace ; class extends AbstractController { public function __construct(private getPropertyType($email_verifier_class_details) ?>$emailVerifier) { } generateRouteForControllerMethod($route_path, $route_name) ?> public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, EntityManagerInterface $entityManager): Response { $user = new (); $form = $this->createForm(::class, $user); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { /** @var string $plainPassword */ $plainPassword = $form->get('plainPassword')->getData(); // encode the plain password $user->set($userPasswordHasher->hashPassword($user, $plainPassword)); $entityManager->persist($user); $entityManager->flush(); // generate a signed url and email it to the user $this->emailVerifier->sendEmailConfirmation('app_verify_email', $user, (new TemplatedEmail()) ->from(new Address('', '')) ->to((string) $user->()) ->subject('Please Confirm your Email') ->htmlTemplate('registration/confirmation_email.html.twig') ); // do anything else you need here, like send an email return $security->login($user, , ''); return $this->redirectToRoute(''); } return $this->render('registration/register.html.twig', [ 'registrationForm' => $form, ]); } generateRouteForControllerMethod('/verify/email', 'app_verify_email') ?> public function verifyUserEmail(Request $request, TranslatorInterface $translator): Response { $this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY'); $id = $request->query->get('id'); if (null === $id) { return $this->redirectToRoute('app_register'); } $repository = $manager->getRepository(::class); $user = $repository->find($id); $user = ->find($id); if (null === $user) { return $this->redirectToRoute('app_register'); } // validate email confirmation link, sets User::isVerified=true and persists try { /** @var $user */ $user = $this->getUser(); $this->emailVerifier->handleEmailConfirmation($request, $user); } catch (VerifyEmailExceptionInterface $exception) { $this->addFlash('verify_email_error', $translator->trans($exception->getReason(), [], 'VerifyEmailBundle')$exception->getReason()); return $this->redirectToRoute(''); } // @TODO Change the redirect on success and handle or remove the flash message in your templates $this->addFlash('success', 'Your email address has been verified.'); return $this->redirectToRoute('app_register'); } }