summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1a93ee4)
Since password are linked to username it was hard to change username while checking that the password is the good one.
Instead of doing crazy things to achieve that, I act that user won't be able to update username.
Also, username (and email) must be unique, since people logged in using username and can request a new password using email.
This should fix #1149
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Entity\User;
use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Entity\User;
use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
-use Wallabag\CoreBundle\Form\Type\UserType;
+use Wallabag\CoreBundle\Form\Type\UserInformationType;
use Wallabag\CoreBundle\Form\Type\NewUserType;
use Wallabag\CoreBundle\Form\Type\RssType;
use Wallabag\CoreBundle\Tools\Utils;
use Wallabag\CoreBundle\Form\Type\NewUserType;
use Wallabag\CoreBundle\Form\Type\RssType;
use Wallabag\CoreBundle\Tools\Utils;
}
// handle changing user information
}
// handle changing user information
- $userForm = $this->createForm(new UserType(), $user);
+ $userForm = $this->createForm(new UserInformationType(), $user);
$userForm->handleRequest($request);
if ($userForm->isValid()) {
$userForm->handleRequest($request);
if ($userForm->isValid()) {
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
use Symfony\Component\Validator\Constraints as Assert;
* @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\UserRepository")
* @ORM\HasLifecycleCallbacks()
* @ExclusionPolicy("all")
* @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\UserRepository")
* @ORM\HasLifecycleCallbacks()
* @ExclusionPolicy("all")
+ *
+ * @UniqueEntity("email")
+ * @UniqueEntity("username")
*/
class User implements AdvancedUserInterface, \Serializable
{
*/
class User implements AdvancedUserInterface, \Serializable
{
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
-class UserType extends AbstractType
+class UserInformationType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
- ->add('username', 'text')
->add('name', 'text')
->add('email', 'text')
->add('save', 'submit')
->add('name', 'text')
->add('email', 'text')
->add('save', 'submit')
public function getName()
{
public function getName()
{
<form action="{{ path('config') }}" method="post" {{ form_enctype(form.user) }}>
{{ form_errors(form.user) }}
<form action="{{ path('config') }}" method="post" {{ form_enctype(form.user) }}>
{{ form_errors(form.user) }}
- <fieldset class="w500p inline">
- <div class="row">
- {{ form_label(form.user.username) }}
- {{ form_errors(form.user.username) }}
- {{ form_widget(form.user.username) }}
- </div>
- </fieldset>
-
<fieldset class="w500p inline">
<div class="row">
{{ form_label(form.user.name) }}
<fieldset class="w500p inline">
<div class="row">
{{ form_label(form.user.name) }}
$this->assertCount(1, $crawler->filter('button[id=config_save]'));
$this->assertCount(1, $crawler->filter('button[id=change_passwd_save]'));
$this->assertCount(1, $crawler->filter('button[id=config_save]'));
$this->assertCount(1, $crawler->filter('button[id=change_passwd_save]'));
- $this->assertCount(1, $crawler->filter('button[id=user_save]'));
+ $this->assertCount(1, $crawler->filter('button[id=update_user_save]'));
$this->assertCount(1, $crawler->filter('button[id=new_user_save]'));
$this->assertCount(1, $crawler->filter('button[id=rss_config_save]'));
}
$this->assertCount(1, $crawler->filter('button[id=new_user_save]'));
$this->assertCount(1, $crawler->filter('button[id=rss_config_save]'));
}
return array(
array(
array(
return array(
array(
array(
- 'user[username]' => '',
- 'user[name]' => '',
- 'user[email]' => '',
+ 'update_user[name]' => '',
+ 'update_user[email]' => '',
),
'This value should not be blank.',
),
array(
array(
),
'This value should not be blank.',
),
array(
array(
- 'user[username]' => 'ad',
- 'user[name]' => '',
- 'user[email]' => '',
- ),
- 'This value is too short.',
- ),
- array(
- array(
- 'user[username]' => 'admin',
- 'user[name]' => '',
- 'user[email]' => 'test',
+ 'update_user[name]' => '',
+ 'update_user[email]' => 'test',
),
'This value is not a valid email address.',
),
),
'This value is not a valid email address.',
),
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertEquals(200, $client->getResponse()->getStatusCode());
- $form = $crawler->filter('button[id=user_save]')->form();
+ $form = $crawler->filter('button[id=update_user_save]')->form();
$crawler = $client->submit($form, $data);
$crawler = $client->submit($form, $data);
$this->assertEquals(200, $client->getResponse()->getStatusCode());
$this->assertEquals(200, $client->getResponse()->getStatusCode());
- $form = $crawler->filter('button[id=user_save]')->form();
+ $form = $crawler->filter('button[id=update_user_save]')->form();
- 'user[username]' => 'admin',
- 'user[name]' => 'new name',
- 'user[email]' => 'admin@wallabag.io',
+ 'update_user[name]' => 'new name',
+ 'update_user[email]' => 'admin@wallabag.io',
);
$client->submit($form, $data);
);
$client->submit($form, $data);
),
'Password should by at least',
),
),
'Password should by at least',
),
+ array(
+ array(
+ 'new_user[username]' => 'admin',
+ 'new_user[password]' => 'wallacewallace',
+ 'new_user[email]' => 'wallace@wallace.me',
+ ),
+ 'This value is already used',
+ ),