Skip to content

Commit

Permalink
#1125 better uniq login/email
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz committed Nov 19, 2024
1 parent e460eea commit 32ad1bc
Show file tree
Hide file tree
Showing 17 changed files with 210 additions and 268 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,84 +12,37 @@

<div class="afup-form">
{{ form_start(form) }}

<p class="note">
*&nbsp;Indique un champ obligatoire
</p>
<fieldset>
<legend>Informations</legend>
<div class="afup-form-container">
<div>
{{ form_errors(form.email) }}
{{ form_label(form.email, 'Email', {'label_attr': {'class': 'libelle'}}) }}
{{ form_widget(form.email, {'attr': {'size': '30', 'maxlength': '100'}}) }}
</div>
<div>
{{ form_errors(form.address) }}
{{ form_label(form.address, 'Address', {'label_attr': {'class': 'libelle'}}) }}
{{ form_widget(form.address, {'attr': {'rows': '4', 'cols': '42'}}) }}
</div>
<div>
{{ form_errors(form.zipcode) }}
{{ form_label(form.zipcode, 'Zip code', {'label_attr': {'class': 'libelle'}}) }}
{{ form_widget(form.zipcode, {'attr': {'size': '6', 'maxlength': '10'}}) }}
</div>
<div>
{{ form_errors(form.city) }}
{{ form_label(form.city, 'City', {'label_attr': {'class': 'libelle'}}) }}
{{ form_widget(form.city, {'attr': {'size': '30', 'maxlength': '50'}}) }}
</div>
<div>
{{ form_errors(form.country) }}
{{ form_label(form.country, 'country', {'label_attr': {'class': 'libelle'}}) }}
{{ form_widget(form.country) }}
</div>
<div>
{{ form_errors(form.phone) }}
{{ form_label(form.phone, 'Landline phone', {'label_attr': {'class': 'libelle'}}) }}
{{ form_widget(form.phone, {'attr': {'size': '20', 'maxlength': '20'}}) }}
</div>
<div>
{{ form_errors(form.mobilephone) }}
{{ form_label(form.mobilephone, 'Mobile phone', {'label_attr': {'class': 'libelle'}}) }}
{{ form_widget(form.mobilephone, {'attr': {'size': '20', 'maxlength': '20'}}) }}
</div>
<div>
{{ form_errors(form.nearest_office) }}
{{ form_label(form.nearest_office, 'Nearest office', {'label_attr': {'class': 'libelle'}}) }}
{{ form_widget(form.nearest_office) }}
</div>
{{ form_errors(form) }}
{{ form_row(form.email) }}
{{ form_row(form.address) }}
{{ form_row(form.zipcode) }}
{{ form_row(form.city) }}
{{ form_row(form.country) }}
{{ form_row(form.phone) }}
{{ form_row(form.mobilephone) }}
{{ form_row(form.nearest_office) }}
</div>
</fieldset>

<fieldset>
<legend>Paramètres</legend>

<legend>Identifiants de connexion</legend>
<div class="afup-form-container">
<div>
{{ form_errors(form.username) }}
{{ form_label(form.username, 'Login', {'label_attr': {'class': 'libelle'}}) }}
{{ form_widget(form.username, {'attr': {'size': '30', 'maxlength': '30'}}) }}
</div>
<div class="afup-form--row">
<p class="note">
Ne renseignez le mot de passe et sa confirmation que si vous souhaitez le changer
</p>
</div>
<div>
{{ form_errors(form.password.first) }}
{{ form_label(form.password.first, 'Password', {'label_attr': {'class': 'libelle'}}) }}
{{ form_widget(form.password.first, {'attr': {'size': '30'}}) }}
</div>
<div>
{{ form_errors(form.password.second) }}
{{ form_label(form.password.second, 'Repeat Password', {'label_attr': {'class': 'libelle'}}) }}
{{ form_widget(form.password.second, {'attr': {'size': '30'}}) }}
</div>
{{ form_row(form.username) }}

<p class="note">
Ne renseignez le mot de passe et sa confirmation que si vous souhaitez le changer
</p>
{{ form_row(form.plainPassword.first) }}
{{ form_row(form.plainPassword.second) }}
</div>
</fieldset>

<p>
<span class="obligatoire">*</span>&nbsp; Indique un champ obligatoire
</p>

<div class="right">
{{ form_widget(form.save, {"attr": {"class": "button button--call-to-action"}}) }}
</div>
Expand Down
9 changes: 5 additions & 4 deletions app/Resources/views/admin/members/user_add.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<div class="ui clearing divider"></div>
<div>
<div class="ui form">
{{ form_errors(form) }}
{{ form_row(form.companyId) }}
{{ form_row(form.civility) }}
{{ form_row(form.lastname, {attr: {'data-role': 'field-lastname'}}) }}
Expand All @@ -19,9 +20,9 @@
{{ form_row(form.address) }}
{{ form_row(form.zipcode) }}
{{ form_row(form.city) }}
{{ form_row(form.countryId) }}
{{ form_row(form.country) }}
{{ form_row(form.phone) }}
{{ form_row(form.cellphone) }}
{{ form_row(form.mobilephone) }}
</div>
</div>
<h2 class="ui header">Paramètres</h2>
Expand All @@ -34,14 +35,14 @@
{{ form_row(form.websiteLevel) }}
{{ form_row(form.officeLevel) }}
{{ form_row(form.status) }}
{{ form_row(form.login, {attr: {'data-role': 'field-login'}}) }}
{{ form_row(form.username, {attr: {'data-role': 'field-login'}}) }}
<div class="inline fields ui grid">
<div class="three wide column"></div>
<div class="field nine wide column">
Ne renseignez le mot de passe et sa confirmation que si vous souhaitez le définir
</div>
</div>
{{ form_row(form.password) }}
{{ form_row(form.plainPassword) }}
{{ form_row(form.roles) }}
{{ form_row(form.needsUpToDateMembership) }}

Expand Down
9 changes: 5 additions & 4 deletions app/Resources/views/admin/members/user_edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<div class="ui clearing divider"></div>
<div>
<div class="ui form">
{{ form_errors(form) }}
{{ form_row(form.companyId) }}
{{ form_row(form.civility) }}
{{ form_row(form.lastname, {attr: {'data-role': 'field-lastname'}}) }}
Expand All @@ -50,9 +51,9 @@
{{ form_row(form.address) }}
{{ form_row(form.zipcode) }}
{{ form_row(form.city) }}
{{ form_row(form.countryId) }}
{{ form_row(form.country) }}
{{ form_row(form.phone) }}
{{ form_row(form.cellphone) }}
{{ form_row(form.mobilephone) }}
</div>
</div>
<h2 class="ui header">Paramètres</h2>
Expand All @@ -65,14 +66,14 @@
{{ form_row(form.websiteLevel) }}
{{ form_row(form.officeLevel) }}
{{ form_row(form.status) }}
{{ form_row(form.login, {attr: {'data-role': 'field-login'}}) }}
{{ form_row(form.username, {attr: {'data-role': 'field-login'}}) }}
<div class="inline fields ui grid">
<div class="three wide column"></div>
<div class="field nine wide column">
Ne renseignez le mot de passe et sa confirmation que si vous souhaitez le changer
</div>
</div>
{{ form_row(form.password) }}
{{ form_row(form.plainPassword) }}
{{ form_row(form.roles) }}
{{ form_row(form.needsUpToDateMembership) }}

Expand Down
3 changes: 0 additions & 3 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,6 @@ services:
AppBundle\Association\UserMembership\UserService:
autowire: true

AppBundle\Association\Form\UserEditFormDataFactory:
autowire: true

AppBundle\Association\Factory\UserFactory:
autowire: true

Expand Down
11 changes: 11 additions & 0 deletions db/migrations/A20241117165505_login_uniq.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Phinx\Migration\AbstractMigration;

class LoginUniq extends AbstractMigration
{
public function change()
{
$this->execute("CREATE UNIQUE INDEX idx_login_unique ON afup_personnes_physiques (login)");
}
}
3 changes: 1 addition & 2 deletions htdocs/templates/site/scss/base/reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ blockquote,
pre,
td,
th,
label,
textarea {
label {
font-size: 1em;
line-height: 1.54;
margin: 10px 0;
Expand Down
1 change: 0 additions & 1 deletion htdocs/templates/site/scss/generic/form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ input, button, select, label {
textarea {
overflow: auto;
min-height: 5em;
font-size: 1.75em;
vertical-align: top;
resize: vertical
}
Expand Down
14 changes: 12 additions & 2 deletions sources/AppBundle/Association/Form/ContactDetailsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace AppBundle\Association\Form;

use Afup\Site\Utils\Pays;
use AppBundle\Association\Model\User;
use AppBundle\Offices\OfficesCollection;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
Expand Down Expand Up @@ -42,6 +43,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
]
])
->add('zipcode', TextType::class, [
'label' => 'Zip code',
'constraints' => [
new NotBlank(),
]
Expand All @@ -52,7 +54,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
]
])
->add('country', ChoiceType::class, [
'label' => 'Pays',
'choices' => $this->getCountyChoices(),
'preferred_choices' => ['FR']
])
->add('phone', TextType::class, [
'required' => false,
Expand All @@ -61,6 +65,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
],
])
->add('mobilephone', TextType::class, [
'label' => 'Portable',
'required' => false,
'constraints' => [
new Length(['max' => 20]),
Expand All @@ -78,18 +83,23 @@ public function buildForm(FormBuilderInterface $builder, array $options)
new Length(['max' => 30]),
]
])
->add('password', RepeatedType::class, [
->add('plainPassword', RepeatedType::class, [
'mapped' => false,
'type' => PasswordType::class,
'required' => false,
'invalid_message' => 'The password fields must match',
'first_options' => ['label' => 'Password'],
'second_options' => ['label' => 'Repeat Password'],
])
->add('save', SubmitType::class, ['label' => 'Update'])
;
}

public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([]);
$resolver->setDefaults([
'data_class' => User::class,
]);
}

private function getOfficesList()
Expand Down
7 changes: 6 additions & 1 deletion sources/AppBundle/Association/Form/UserEditFormData.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
namespace AppBundle\Association\Form;

use AppBundle\Association\Model\User;
use AppBundle\Validator\Constraints as AppAssert;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;

/**
* @AppAssert\UniqueEntity(fields={"username"}, repository="\AppBundle\Association\Model\Repository\UserRepository")
* @AppAssert\UniqueEntity(fields={"email"}, repository="\AppBundle\Association\Model\Repository\UserRepository")
*/
class UserEditFormData
{
public $companyId;
Expand Down Expand Up @@ -85,7 +90,7 @@ class UserEditFormData
* @Assert\NotBlank()
* @Assert\Length(max=30)
*/
public $login;
public $username;
/**
* @Assert\Length(max=30)
*/
Expand Down
85 changes: 0 additions & 85 deletions sources/AppBundle/Association/Form/UserEditFormDataFactory.php

This file was deleted.

Loading

0 comments on commit 32ad1bc

Please sign in to comment.