diff --git a/src/Controller/CapsuleEditorController.php b/src/Controller/CapsuleEditorController.php index 6b08bbcbecb0eaa7f098600e2e17fa56a4f86750..0cc7c3de8b75de491138d3b38e1fcf4252f17827 100755 --- a/src/Controller/CapsuleEditorController.php +++ b/src/Controller/CapsuleEditorController.php @@ -278,9 +278,6 @@ class CapsuleEditorController extends AbstractController int $capsule_id, Request $request ): Response { - $form = $this->createForm(RemoveEditorFormType::class); - $form->handleRequest($request); - $capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]); if (! $capsule instanceof Capsule) { throw new \Exception('The retrieved capsule is not an instance of Capsule.'); @@ -289,6 +286,9 @@ class CapsuleEditorController extends AbstractController $pending_editor_invitation = $this->capsule_pending_editor_invitation_repository ->findOneBy(['id' => $pending_editor_invitation_id]); + $form = $this->createForm(RemoveEditorFormType::class); + $form->handleRequest($request); + if (! $pending_editor_invitation instanceof PendingEditorInvitation) { $this->addFlash( 'warning', diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php index 4155bb7e618a1911940add7a8a17a066a05719f8..e6410636e992e254eae341243c741209ad1e4129 100755 --- a/src/Controller/RegistrationController.php +++ b/src/Controller/RegistrationController.php @@ -69,7 +69,7 @@ class RegistrationController extends AbstractController } return $this->renderForm('registration/register.html.twig', [ - 'registrationForm' => $form, + 'registrationForm' => $form ]); } @@ -92,7 +92,7 @@ class RegistrationController extends AbstractController try { $this->email_verifier->handleEmailConfirmation($request, $user); } catch (VerifyEmailExceptionInterface $exception) { - $this->addFlash('verify_email_error', $exception->getReason()); + $this->addFlash('error', $exception->getReason()); return $this->redirectToRoute('app_register'); } diff --git a/src/Controller/ResetPasswordController.php b/src/Controller/ResetPasswordController.php index 7169714865de8548846371b272e0a61d08617644..a58c51a80a2cbf43725301164807baafaf8b95ef 100755 --- a/src/Controller/ResetPasswordController.php +++ b/src/Controller/ResetPasswordController.php @@ -43,7 +43,7 @@ class ResetPasswordController extends AbstractController } return $this->renderForm('reset_password/request.html.twig', [ - 'requestForm' => $form, + 'requestForm' => $form ]); } @@ -118,7 +118,7 @@ class ResetPasswordController extends AbstractController } return $this->renderForm('reset_password/reset.html.twig', [ - 'resetForm' => $form, + 'resetForm' => $form ]); } diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 52c454c658b8d020c01beba889593f520518ba45..91b811c04ef6b17f3b9679553607f0f27554735a 100755 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -44,18 +44,38 @@ class UserController extends AbstractController return $this->redirectToRoute('app_logout'); } - $form = $this->createForm(EditUserProfileFormType::class, $current_user); - - $form->setData($current_user); + $form = $this->createForm( + EditUserProfileFormType::class, + $current_user, + ['current_email_address' => $current_user->getEmail()] + ); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->entity_manager->persist($current_user); $this->entity_manager->flush(); + $current_user->setFirstName($form->get('firstName')->getData()); + $current_user->setLastName($form->get('lastName')->getData()); + $this->entity_manager->persist($current_user); + $this->entity_manager->flush(); + + $new_email_address = $form->get('email')->getData(); + if ($current_user->getEmail() !== $new_email_address) { + $this->addFlash( + 'warning', + $this->translator->trans('user.profile.updated.warning', [ + 'new_email_address' => $new_email_address + ]) + ); + + return $this->render('user/edit_email_address.html.twig', [ + 'new_email_address' => $form->get('email')->getData() + ]); + } $this->addFlash( - 'profile_updated_success', - $this->translator->trans('user.profile.updated_success') + 'success', + $this->translator->trans('user.profile.updated.success') ); return $this->redirectToRoute('show_profile'); diff --git a/src/Form/EditUserProfileFormType.php b/src/Form/EditUserProfileFormType.php index 637d12bdd87d4175bb1358b739fa0e6b51b0ec18..a78a51ee2a4858f77e428d08821955e278c23a29 100755 --- a/src/Form/EditUserProfileFormType.php +++ b/src/Form/EditUserProfileFormType.php @@ -12,6 +12,7 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Security\Core\Validator\Constraints\UserPassword; use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\Constraints as Assert; class EditUserProfileFormType extends AbstractType { @@ -40,9 +41,14 @@ class EditUserProfileFormType extends AbstractType 'email', EmailType::class, [ - 'constraints' => [new NotBlank(['message' => 'email.not_blank'])], + 'data' => $options['current_email_address'], + 'constraints' => [ + new NotBlank(['message' => 'email.not_blank']), + new Assert\Email() + ], 'label' => 'general.email', - 'empty_data' => '' + 'empty_data' => '', + 'mapped' => false, ] ) ->add( @@ -70,6 +76,8 @@ class EditUserProfileFormType extends AbstractType { $resolver->setDefaults([ 'data_class' => User::class, + 'current_email_address' => '' ]); +// $resolver->setAllowedTypes('current_email_address', 'string'); } } diff --git a/templates/capsule/editors/list_editors.html.twig b/templates/capsule/editors/list_editors.html.twig index 4a04b8997e0c998d9bb57eb18d6e6baf8c91c020..0b71139fb3a355c7088c6e6ea959357c2dc45914 100644 --- a/templates/capsule/editors/list_editors.html.twig +++ b/templates/capsule/editors/list_editors.html.twig @@ -18,13 +18,13 @@ </div> {% for flashWarning in app.flashes('warning') %} - <div class="text-center alert alert-warning col-5 mx-auto my-5 mt-2" role="alert"> + <div class="text-center alert alert-warning col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 mt-2" role="alert"> {{ flashWarning }} </div> {% endfor %} {% for flashSuccess in app.flashes('success') %} - <div class="text-center alert alert-success col-5 mx-auto my-5 mt-2" role="alert"> + <div class="text-center alert alert-success col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 mt-2" role="alert"> {{ flashSuccess }} </div> {% endfor %} diff --git a/templates/capsule/groups/capsule_groups.html.twig b/templates/capsule/groups/capsule_groups.html.twig index 5129485dccce24ff3c8181cdfa6f98efc7461908..ad38080a086ba9178f00752cbd144c58053aef3c 100644 --- a/templates/capsule/groups/capsule_groups.html.twig +++ b/templates/capsule/groups/capsule_groups.html.twig @@ -18,13 +18,13 @@ </div> {% for flashWarning in app.flashes('warning') %} - <div class="text-center alert alert-warning col-5 mx-auto my-5 mt-2" role="alert"> + <div class="text-center alert alert-warning col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 mt-2" role="alert"> {{ flashWarning }} </div> {% endfor %} {% for flashSuccess in app.flashes('success') %} - <div class="text-center alert alert-success col-5 mx-auto my-5 mt-2" role="alert"> + <div class="text-center alert alert-success col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 mt-2" role="alert"> {{ flashSuccess }} </div> {% endfor %} diff --git a/templates/capsule/groups/user_groups.html.twig b/templates/capsule/groups/user_groups.html.twig index d0737cc1dd680adfb544ed8164cb5b06877b2922..808b416dd7f22040826f594ff249afb6cb725fb6 100644 --- a/templates/capsule/groups/user_groups.html.twig +++ b/templates/capsule/groups/user_groups.html.twig @@ -17,13 +17,13 @@ </div> {% for flashWarning in app.flashes('warning') %} - <div class="text-center alert alert-warning col-5 mx-auto my-5 mt-2" role="alert"> + <div class="text-center alert alert-warning col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 mt-2" role="alert"> {{ flashWarning }} </div> {% endfor %} {% for flashSuccess in app.flashes('success') %} - <div class="text-center alert alert-success col-5 mx-auto my-5 mt-2" role="alert"> + <div class="text-center alert alert-success col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 mt-2" role="alert"> {{ flashSuccess }} </div> {% endfor %} diff --git a/templates/capsule/index.html.twig b/templates/capsule/index.html.twig index 5c47a37681b8d7f75caa82c8f17321344afd3025..59b64dbb425eb630fd4ab7dc3bcc59b88974d6ff 100644 --- a/templates/capsule/index.html.twig +++ b/templates/capsule/index.html.twig @@ -34,13 +34,13 @@ </div> {% for flashWarning in app.flashes('warning') %} - <div class="text-center alert alert-warning col-5 mx-auto my-5" role="alert"> + <div class="text-center alert alert-warning col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5" role="alert"> {{ flashWarning }} </div> {% endfor %} {% for flashSuccess in app.flashes('success') %} - <div class="text-center alert alert-success col-5 mx-auto my-5" role="alert"> + <div class="text-center alert alert-success col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5" role="alert"> {{ flashSuccess }} </div> {% endfor %} diff --git a/templates/legacy/legacy.html.twig b/templates/legacy/legacy.html.twig index 2bf7dbff33604db8efb47927cc9ace0ebe255cf6..8d4d49edc75d8e73e079d838e895ddc18c38ce1d 100644 --- a/templates/legacy/legacy.html.twig +++ b/templates/legacy/legacy.html.twig @@ -1,21 +1,14 @@ {% extends 'layout.html.twig' %} - - {% block body %} <iframe src="{{ url }}" style="width:100%;height:100%;top:0;left:0;position:absolute" - {# width="1200" - height="600" #} - frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen> </iframe> - - {% endblock %} diff --git a/templates/registration/register.html.twig b/templates/registration/register.html.twig index 3f9b4c0bbb3a2729667eb6f563ba0a38c0c7f360..99d5864530a878b05bb61cf9f2bcee6d7bbfa18e 100644 --- a/templates/registration/register.html.twig +++ b/templates/registration/register.html.twig @@ -6,8 +6,10 @@ {% block body %} <div class="mt-4"> - {% for flashError in app.flashes('verify_email_error') %} - <div class="alert alert-danger col-6 mx-auto my-5 h1" role="alert">{{ flashError }}</div> + {% for flashError in app.flashes('error') %} + <div class="alert alert-danger col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5 h1" role="alert"> + {{ flashError }} + </div> {% endfor %} {{ form_start(registrationForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-column justify-content-center'}}) }} diff --git a/templates/user/edit_email_address.html.twig b/templates/user/edit_email_address.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..a3017afedbc6e31f977ba10c7500e4d93edf7f7c --- /dev/null +++ b/templates/user/edit_email_address.html.twig @@ -0,0 +1,21 @@ +{% extends 'layout.html.twig' %} + +{% block title %} + {{ 'user.edit_email_address'|trans }} +{% endblock %} + +{% block body %} + <div class="row gx-0"> + <div class="row-title-box"> + <h3 class="row-title"> + {{ 'user.edit_email_address'|trans }} + </h3> + </div> + </div> + + {% for flashWarning in app.flashes('warning') %} + <div class="text-center alert alert-warning col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5" role="alert"> + {{ flashWarning }} + </div> + {% endfor %} +{% endblock %} \ No newline at end of file diff --git a/templates/user/profile.html.twig b/templates/user/profile.html.twig index a02eef8a508eff07569d36094696c98db223f43f..5747fed46c4fc95bf01e3d5ddaac4869da530798 100644 --- a/templates/user/profile.html.twig +++ b/templates/user/profile.html.twig @@ -13,12 +13,18 @@ </div> </div> - {% for flashSuccess in app.flashes('profile_updated_success') %} - <div class="text-center alert alert-success col-5 mx-auto my-5" role="alert"> + {% for flashSuccess in app.flashes('success') %} + <div class="text-center alert alert-success col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5" role="alert"> {{ flashSuccess }} </div> {% endfor %} + {% for flashWarning in app.flashes('warning') %} + <div class="text-center alert alert-warning col-11 col-md-10 col-lg-9 col-xl-8 mx-auto my-5" role="alert"> + {{ flashWarning }} + </div> + {% endfor %} + <div class="d-flex flex-column flex-md-row justify-content-center align-items-center"> <div class="profile-block d-flex flex-row ps-3 ps-md-5 pe-3 pe-md-5 pt-4 pb-3 fw-normal me-0 me-md-5"> <div class="pe-3 pe-md-4 text-nowrap"> diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index 9b2e68d9d6f9be9aa298936367f51412c3dd0f62..012af5a9acc861991c1324ed1713bcd8035a9f32 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -107,7 +107,10 @@ user: title: My profile edit: Edit profile update: Update - updated_success: The profile has been updated + updated: + success: The profile has been updated + warning: In order to update your current email address related to your Memorekall account with the new email address new_email_address, + please confirm this change following the link your received by email. password: edit: Edit password current: Current password @@ -115,6 +118,7 @@ user: updated_success: The password has been updated edit_profile: Edit my profile edit_password: Edit my password + edit_email_address: Edit my email address editors: title: Editors diff --git a/translations/messages.fr.yaml b/translations/messages.fr.yaml index 55f20cea6a443e77c30b740689f2b7fbcb91b0fc..b2e4e2695140508c1a3e11e8116608e110865dab 100644 --- a/translations/messages.fr.yaml +++ b/translations/messages.fr.yaml @@ -106,7 +106,9 @@ user: title: Mon profil edit: Modifier mon profil update: Mettre à jour - updated_success: Votre profil a bien été mis à jour + updated: + success: Votre profil a bien été mis à jour + warning: Veuillez confirmer le changement d'adresse e-mail en activant le lien que vous avez reçu par mail à l'adresse new_email_address. L'adresse e-amil reliée à votre compte Memorekall sera alors mise à jour avec la nouvelle new_email_address. password: edit: Modifier mon mot de passe current: Mot de passe actuel @@ -114,6 +116,7 @@ user: updated_success: Votre mot de passe a bien été modifié edit_profile: Modifier mon mot de passe edit_password: Modifier mon mot de passe + edit_email_address: Modifier mon adresse e-mail editors: title: Editeurs d'une capsule