|
|
|
@ -60,18 +60,19 @@ class UserController extends AbstractController {
|
|
|
|
|
$form->handleRequest($request);
|
|
|
|
|
|
|
|
|
|
if ($form->isSubmitted() && $form->isValid()) {
|
|
|
|
|
// encode the plain password
|
|
|
|
|
//region encode the plain password
|
|
|
|
|
$user->setPassword(
|
|
|
|
|
$userPasswordHasher->hashPassword(
|
|
|
|
|
$user,
|
|
|
|
|
$form->get('newPassword')->getData()
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
//endregion
|
|
|
|
|
|
|
|
|
|
$entityManager->persist($user);
|
|
|
|
|
$entityManager->flush();
|
|
|
|
|
|
|
|
|
|
// Generate the mail with the link to verify the account
|
|
|
|
|
//region Generate the mail with the link to verify the account
|
|
|
|
|
$this->emailVerifier->sendEmailConfirmation(
|
|
|
|
|
'user_mailVerify',
|
|
|
|
|
$user,
|
|
|
|
@ -83,11 +84,12 @@ class UserController extends AbstractController {
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
->to($user->getEmail())
|
|
|
|
|
->subject('Please Confirm your Email')
|
|
|
|
|
->htmlTemplate('user/confirmation_email.html.twig')
|
|
|
|
|
->subject($this->translator->trans('emails.emailConfirmation.subject'))
|
|
|
|
|
->htmlTemplate('user/emailConfirmation.html.twig')
|
|
|
|
|
);
|
|
|
|
|
//endregion
|
|
|
|
|
|
|
|
|
|
$this->addFlash('info', 'Please validate your account through the confirmation mail');
|
|
|
|
|
$this->addFlash('info', $this->translator->trans('pages.signUp.emailConfirmationMessage'));
|
|
|
|
|
return $this->redirectToRoute('core_main');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -106,22 +108,26 @@ class UserController extends AbstractController {
|
|
|
|
|
*/
|
|
|
|
|
#[Route('/emailVerify', name: 'user_mailVerify')]
|
|
|
|
|
public function verifyUserEmail (Request $request, TranslatorInterface $translator, UserRepository $userRepository): Response {
|
|
|
|
|
//region Get the user id from query
|
|
|
|
|
$id = $request->query->get('id');
|
|
|
|
|
if ($id === null) {
|
|
|
|
|
$this->addFlash('danger', $this->translator->trans('pages.emailVerify.errorId'));
|
|
|
|
|
return $this->redirectToRoute('user_signUp');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//endregion
|
|
|
|
|
//region Get the user himself
|
|
|
|
|
$user = $userRepository->find($id);
|
|
|
|
|
if ($user === null) {
|
|
|
|
|
$this->addFlash('danger', $this->translator->trans('pages.emailVerify.errorUser'));
|
|
|
|
|
return $this->redirectToRoute('user_signUp');
|
|
|
|
|
}
|
|
|
|
|
//endregion
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$this->emailVerifier->handleEmailConfirmation($request, $user);
|
|
|
|
|
}
|
|
|
|
|
catch (VerifyEmailExceptionInterface $exception) {
|
|
|
|
|
$this->addFlash('verify_email_error', $translator->trans($exception->getReason(), [], 'VerifyEmailBundle'));
|
|
|
|
|
|
|
|
|
|
return $this->redirectToRoute('user_signUp');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -143,7 +149,12 @@ class UserController extends AbstractController {
|
|
|
|
|
if ($user !== null) {
|
|
|
|
|
$this->addFlash(
|
|
|
|
|
'warning',
|
|
|
|
|
'You are already logged in, please <a href="' . $this->generateUrl('user_signOut') . '">sign out</a> first.'
|
|
|
|
|
$this->translator->trans(
|
|
|
|
|
'pages.emailVerify.warningAlreadyConnected',
|
|
|
|
|
[
|
|
|
|
|
'signOutUrl' => $this->generateUrl('user_signOut'),
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|