Skip to content
Snippets Groups Projects
Commit a59ddf32 authored by Camille Simiand's avatar Camille Simiand
Browse files

Refacto + umap email field

parent dd76f01b
Branches
Tags
1 merge request!69tuleap-142-when-editing-email-address-user-should-confirm-it-with-email-validation
Showing
with 92 additions and 35 deletions
......@@ -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',
......
......
......@@ -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');
}
......
......
......@@ -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
]);
}
......
......
......@@ -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(
'profile_updated_success',
$this->translator->trans('user.profile.updated_success')
'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(
'success',
$this->translator->trans('user.profile.updated.success')
);
return $this->redirectToRoute('show_profile');
......
......
......@@ -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');
}
}
......@@ -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 %}
......
......
......@@ -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 %}
......
......
......@@ -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 %}
......
......
......@@ -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 %}
......
......
{% 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 %}
......@@ -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'}}) }}
......
......
{% 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
......@@ -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">
......
......
......@@ -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
......
......
......@@ -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
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment