query->get('id'); if (null === $id) { return $this->redirectToRoute('app_register'); } $user = $userRepository->find($id); if (null === $user) { return $this->redirectToRoute('app_register'); } // validate email confirmation link, sets User::isVerified=true and persists try { $emailVerifier->handleEmailConfirmation($request, $user); } catch (VerifyEmailExceptionInterface $exception) { $this->addFlash('error', $exception->getReason() . ' If the link has expired, you can request a new one here.'); return $this->redirectToRoute('app_register'); } $this->addFlash('success', 'Your email address has been verified. You can now log in.'); return $this->redirectToRoute('app_login'); } }