Skip to content

Commit

Permalink
added account recovery data edit page #797
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermednt committed Aug 7, 2018
1 parent e64f527 commit a014b25
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class AccountRecoveryDataController extends Controller
{
/**
* @Route("/account-recovery-data")
* @Route("/account-recovery-data", name="account_recovery_edit")
* @Template()
*/
public function editAction(Request $request)
Expand All @@ -37,11 +37,12 @@ public function editAction(Request $request)
$form->handleRequest($request);
if ($form->isValid()) {
$this->getDoctrine()->getManager()->flush();

return $this->redirectToRoute('account_recovery_edit');
}

return [
'form' => $form->createView(),
];
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ class AccountRecoveryData
* @var string
*
* @ORM\Column(name="email", type="string", length=255, nullable=true)
* @LCAssert\Email(strict=true)
* @Assert\NotBlank(message="person.validation.email.not_blank")
* @Assert\Expression("value != this.getPerson().getEmail()")
* @LCAssert\Email(strict=true, optional=true)
* @Assert\Expression("value != this.getPerson().getEmail()", message="account_recovery.edit.email.should_be_different")
*/
private $email;

Expand All @@ -69,7 +68,7 @@ class AccountRecoveryData
* type="mobile",
* groups={"Registration", "LoginCidadaoRegistration", "Dynamic", "Profile", "LoginCidadaoProfile"}
* )
* @Assert\Expression("value != this.getPerson().getMobile()")
* @Assert\Expression("value != this.getPerson().getMobile()", message="account_recovery.edit.phone.should_be_different")
*/
private $mobile;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,24 @@ class AccountRecoveryDataType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('email', EmailType::class)
->add('mobile', PhoneNumberType::class,
[
'required' => false,
'label' => 'person.form.mobile.label',
'attr' => [
'class' => 'form-control intl-tel',
'placeholder' => 'person.form.mobile.placeholder',
],
'label_attr' => ['class' => 'intl-tel-label'],
'format' => PhoneNumberFormat::E164,
]);
->add('email', EmailType::class, [
'required' => false,
'label' => 'account_recovery.form.email.label',
'attr' => [
'class' => 'form-control',
'placeholder' => 'account_recovery.form.email.placeholder',
],
])
->add('mobile', PhoneNumberType::class, [
'required' => false,
'label' => 'account_recovery.form.mobile.label',
'attr' => [
'class' => 'form-control intl-tel',
'placeholder' => 'account_recovery.form.mobile.placeholder',
],
'label_attr' => ['class' => 'intl-tel-label'],
'format' => PhoneNumberFormat::E164,
]);
}

/**
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
account_recovery:
edit:
title: 'Informações de Contato Alternativas'
description: 'Cadastre meios de contato alternativos para que você consiga recuperar sua conta caso perca acesso ao seu email e celular principais.'
form:
email:
label: 'Email Alternativo'
placeholder: 'Digite seu email alternativo'
mobile:
label: 'Celular Alternativo'
placeholder: 'Digite seu celular alternativo'
submit: 'Salvar'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
account_recovery:
edit:
email:
should_be_different: 'Your recovery email must be different from your main email.'
phone:
should_be_different: 'Your recovery phone must be different from your main phone number.'
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
account_recovery:
edit:
email:
should_be_different: 'Seu email alternativo deve ser diferente do seu email principal.'
phone:
should_be_different: 'Seu telefone alternativo deve ser diferente do seu telefone principal.'
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
{% extends "::base.html.twig" %}
{% extends 'LoginCidadaoCoreBundle::compact.base.html.twig' %}

{% block panel_body_class %}account-recovery-data-edit{% endblock %}

{% block title %}LoginCidadaoCoreBundle:AccountRecoveryData:edit{% endblock %}

{% block body %}
<h1>Welcome to the AccountRecoveryData:edit page</h1>
{% block panel_body %}
<h1>{{ 'account_recovery.edit.title' | trans }}</h1>

<p>{{ 'account_recovery.edit.description' | trans }}</p>

{{ form_start(form) }}
<button type="submit">Submit</button>
<div class="form-group">
{{ form_label(form.email, null, {'label_attr': {'class': 'sr-only'}}) }}
<div class="input-group">
<div class="input-group-addon">
<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span>
</div>
{{ form_widget(form.email) }}
</div>
<div class="has-error">{{ form_errors(form.email) }}</div>
</div>

<div class="form-group">
{{ form_label(form.mobile, null, {'label_attr': {'class': 'sr-only'}}) }}
<div class="input-group">
<div class="input-group-addon">
<span class="glyphicon glyphicon-phone" aria-hidden="true"></span>
</div>
{{ form_widget(form.mobile) }}
</div>
<div class="has-error">{{ form_errors(form.mobile) }}</div>
</div>

<button class="btn btn-block btn-success" type="submit">
{{ 'account_recovery.form.submit' | trans }}
</button>
{{ form_end(form) }}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class EmailValidator extends \Symfony\Component\Validator\Constraints\EmailValid
*/
public function validate($value, Constraint $constraint)
{
if (null === $value || '' === $value) {
return;
}

if ($constraint->strict) {
if (!class_exists('\Egulias\EmailValidator\EmailValidator') || !class_exists('\Egulias\EmailValidator\Validation\RFCValidation')) {
throw new RuntimeException('Strict email validation requires egulias/email-validator');
Expand Down

0 comments on commit a014b25

Please sign in to comment.