diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index f10d1eb263a484b178e19dbe512ffbea4bc146d0..4122df2fe82ed101706283188df40847e2320c6f 100755 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -70,6 +70,13 @@ class UserController extends AbstractController if ($form->isSubmitted() && $form->isValid()) { if ($current_user->getEmail() !== $form->get('email')->getData()) { + $last_pending_email_address = $this->pending_email_address_repository->findOneBy( + ['user' => $current_user->getId()] + ); + if ($last_pending_email_address !== null) { + $this->entity_manager->remove($last_pending_email_address); + } + $pending_email_address = new PendingEmailAddress(); $pending_email_address->setEmail($form->get('email')->getData()); $pending_email_address->setUser($current_user); @@ -146,7 +153,7 @@ class UserController extends AbstractController ]); } - #[Route('/edit/email/', name:'verify_new_email_address')] + #[Route('/edit/email', name:'verify_new_email_address')] public function verifyNewEmailAddress(): Response { $current_user = $this->getUser(); @@ -157,7 +164,7 @@ class UserController extends AbstractController $pending_email_address = $this->pending_email_address_repository->findOneBy(['user' => $current_user->getId()]); if (! $pending_email_address instanceof PendingEmailAddress) { - throw new \Exception('Not found'); + throw new \Exception('Pending email address not found'); } $current_user->setEmail($pending_email_address->getEmail()); diff --git a/templates/user/edit_profile.html.twig b/templates/user/edit_profile.html.twig index 57a83762c698e8447599f715fe2c8edc904b1fc3..d916e3c64bb9c12a9afb2e11de4498a47ebdf755 100644 --- a/templates/user/edit_profile.html.twig +++ b/templates/user/edit_profile.html.twig @@ -23,5 +23,4 @@ {{ form_row(editUserProfileForm.update, {'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-4 col-2'}}) }} {{ form_end(editUserProfileForm) }} </div> - {% endblock %} \ No newline at end of file diff --git a/templates/user/update_email.html.twig b/templates/user/update_email.html.twig index 082e02f6230c9c0fe78ac70ba62a28c7d9d46bba..6be99dbe2a861b24cf41f25a8eef8c4c429e7768 100644 --- a/templates/user/update_email.html.twig +++ b/templates/user/update_email.html.twig @@ -5,7 +5,7 @@ <p> {{ 'user.edit.email.text'|trans }}: <br><br> - <a href="{{ path('verify_new_email_address') }}"> + <a href="{{ url('verify_new_email_address') }}"> {{ 'user.edit.email.confirm_email'|trans }} </a> {{ 'general.link_expire'|trans