Skip to content
Snippets Groups Projects
Commit 9bef5298 authored by David Beniamine's avatar David Beniamine
Browse files

Merge branch 'tuleap-74-add-a-repeat-password-field-in-registration-form' into 'main'

Add a repeat password field in registration form

See merge request !15
parents 6533e26d 54e1db6b
No related branches found
No related tags found
1 merge request!15Add a repeat password field in registration form
......@@ -106,7 +106,6 @@ class RegistrationController extends AbstractController
return $this->redirectToRoute('app_register');
}
// @TODO Change the redirect on success and handle or remove the flash message in your templates
$this->addFlash('success', 'Your email address has been verified.');
return $this->redirectToRoute('app_login');
......@@ -120,8 +119,9 @@ class RegistrationController extends AbstractController
$userid = $this->requestStack->getSession()->get('userid');
$user = $userRepository->find($userid);
return $this->render('registration/register_mail_sent.html.twig', [
'user' => $user,
]);
return $this->render(
'registration/register_mail_sent.html.twig',
['user' => $user]
);
}
}
......@@ -8,6 +8,7 @@ use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
......@@ -21,8 +22,7 @@ class RegistrationFormType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('email', EmailType::class, [
])
->add('email', EmailType::class, [])
->add('agreeTerms', CheckboxType::class, [
'mapped' => false,
'constraints' => [
......@@ -32,9 +32,10 @@ class RegistrationFormType extends AbstractType
],
'label' => 'Accept terms and conditions'
])
->add('plainPassword', PasswordType::class, [
->add('plainPassword', RepeatedType::class, [
// instead of being set onto the object directly,
// this is read and encoded in the controller
'type' => PasswordType::class,
'mapped' => false,
'attr' => ['autocomplete' => 'new-password'],
'constraints' => [
......@@ -48,6 +49,9 @@ class RegistrationFormType extends AbstractType
'max' => 4096,
]),
],
'first_options' => ['label' => 'Password'],
'second_options' => ['label' => 'Repeat password'],
'invalid_message' => 'The password fields must match'
])
->add(
'firstName',
......
......@@ -11,11 +11,8 @@
{{ form_row(registrationForm.firstName, {'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-4 col-6'}}) }}
{{ form_row(registrationForm.lastName, {'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-4 col-6'}}) }}
{{ form_row(registrationForm.email, {'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-4 col-6'}}) }}
{{ form_row(registrationForm.plainPassword, {
label: 'Password'
, 'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-4 col-6'}
}) }}
{{ form_row(registrationForm.plainPassword.first, {'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-4 col-6'}}) }}
{{ form_row(registrationForm.plainPassword.second, {'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-4 col-6'}}) }}
{{ form_row(registrationForm.captcha, {'row_attr': {'class' : 'form-group d-flex flex-column m-auto mb-5 col-6'}}) }}
{{ form_row(registrationForm.agreeTerms, {'row_attr': {'class' : 'form-group d-flex flex-row m-auto mb-4 col-6 justify-content-center'},
'label_attr': { 'class' : 'ms-3'},
......
......@@ -4,7 +4,7 @@
{% block body %}
<div class="container d-flex flex-row justify-content-center">
<div class="col-6">
<p class="alert">An email has been sent to {{ user.getEmail() }} . It contains an activation link you must click to activate your account</p>
<p class="alert">An email has been sent to {{ user.getEmail() }}. It contains an activation link you must click to activate your account.</p>
</div>
</div>
{% endblock %}
\ No newline at end of file
......@@ -127,7 +127,8 @@ class RegistrationControllerTest extends WebTestCase
$form['registration_form[firstName]'] = 'new User FirstName';
$form['registration_form[lastName]'] = 'new User LastName';
$form['registration_form[email]'] = $userEmail;
$form['registration_form[plainPassword]'] = 'password';
$form['registration_form[plainPassword][first]'] = 'password';
$form['registration_form[plainPassword][second]'] = 'password';
$form['registration_form[agreeTerms]'] = 1;
$client->submit($form);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment