diff options
-rw-r--r-- | src/Wallabag/CoreBundle/Controller/ConfigController.php | 4 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/User.php | 4 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Form/Type/UserInformationType.php (renamed from src/Wallabag/CoreBundle/Form/Type/UserType.php) | 5 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig | 8 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php | 37 |
5 files changed, 25 insertions, 33 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index dbae3ea7..898c291f 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php | |||
@@ -9,7 +9,7 @@ use Symfony\Component\HttpFoundation\JsonResponse; | |||
9 | use Wallabag\CoreBundle\Entity\Config; | 9 | use Wallabag\CoreBundle\Entity\Config; |
10 | use Wallabag\CoreBundle\Entity\User; | 10 | use Wallabag\CoreBundle\Entity\User; |
11 | use Wallabag\CoreBundle\Form\Type\ChangePasswordType; | 11 | use Wallabag\CoreBundle\Form\Type\ChangePasswordType; |
12 | use Wallabag\CoreBundle\Form\Type\UserType; | 12 | use Wallabag\CoreBundle\Form\Type\UserInformationType; |
13 | use Wallabag\CoreBundle\Form\Type\NewUserType; | 13 | use Wallabag\CoreBundle\Form\Type\NewUserType; |
14 | use Wallabag\CoreBundle\Form\Type\RssType; | 14 | use Wallabag\CoreBundle\Form\Type\RssType; |
15 | use Wallabag\CoreBundle\Tools\Utils; | 15 | use Wallabag\CoreBundle\Tools\Utils; |
@@ -65,7 +65,7 @@ class ConfigController extends Controller | |||
65 | } | 65 | } |
66 | 66 | ||
67 | // handle changing user information | 67 | // handle changing user information |
68 | $userForm = $this->createForm(new UserType(), $user); | 68 | $userForm = $this->createForm(new UserInformationType(), $user); |
69 | $userForm->handleRequest($request); | 69 | $userForm->handleRequest($request); |
70 | 70 | ||
71 | if ($userForm->isValid()) { | 71 | if ($userForm->isValid()) { |
diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php index e75e3a83..63ec072c 100644 --- a/src/Wallabag/CoreBundle/Entity/User.php +++ b/src/Wallabag/CoreBundle/Entity/User.php | |||
@@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Entity; | |||
4 | 4 | ||
5 | use Doctrine\Common\Collections\ArrayCollection; | 5 | use Doctrine\Common\Collections\ArrayCollection; |
6 | use Doctrine\ORM\Mapping as ORM; | 6 | use Doctrine\ORM\Mapping as ORM; |
7 | use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; | ||
7 | use Symfony\Component\Security\Core\User\UserInterface; | 8 | use Symfony\Component\Security\Core\User\UserInterface; |
8 | use Symfony\Component\Security\Core\User\AdvancedUserInterface; | 9 | use Symfony\Component\Security\Core\User\AdvancedUserInterface; |
9 | use Symfony\Component\Validator\Constraints as Assert; | 10 | use Symfony\Component\Validator\Constraints as Assert; |
@@ -17,6 +18,9 @@ use JMS\Serializer\Annotation\Expose; | |||
17 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\UserRepository") | 18 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\UserRepository") |
18 | * @ORM\HasLifecycleCallbacks() | 19 | * @ORM\HasLifecycleCallbacks() |
19 | * @ExclusionPolicy("all") | 20 | * @ExclusionPolicy("all") |
21 | * | ||
22 | * @UniqueEntity("email") | ||
23 | * @UniqueEntity("username") | ||
20 | */ | 24 | */ |
21 | class User implements AdvancedUserInterface, \Serializable | 25 | class User implements AdvancedUserInterface, \Serializable |
22 | { | 26 | { |
diff --git a/src/Wallabag/CoreBundle/Form/Type/UserType.php b/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php index b479a0b5..617722db 100644 --- a/src/Wallabag/CoreBundle/Form/Type/UserType.php +++ b/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php | |||
@@ -5,12 +5,11 @@ use Symfony\Component\Form\AbstractType; | |||
5 | use Symfony\Component\Form\FormBuilderInterface; | 5 | use Symfony\Component\Form\FormBuilderInterface; |
6 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; | 6 | use Symfony\Component\OptionsResolver\OptionsResolverInterface; |
7 | 7 | ||
8 | class UserType extends AbstractType | 8 | class UserInformationType extends AbstractType |
9 | { | 9 | { |
10 | public function buildForm(FormBuilderInterface $builder, array $options) | 10 | public function buildForm(FormBuilderInterface $builder, array $options) |
11 | { | 11 | { |
12 | $builder | 12 | $builder |
13 | ->add('username', 'text') | ||
14 | ->add('name', 'text') | 13 | ->add('name', 'text') |
15 | ->add('email', 'text') | 14 | ->add('email', 'text') |
16 | ->add('save', 'submit') | 15 | ->add('save', 'submit') |
@@ -26,6 +25,6 @@ class UserType extends AbstractType | |||
26 | 25 | ||
27 | public function getName() | 26 | public function getName() |
28 | { | 27 | { |
29 | return 'user'; | 28 | return 'update_user'; |
30 | } | 29 | } |
31 | } | 30 | } |
diff --git a/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig index f2a98dfb..c90bb2e3 100644 --- a/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig | |||
@@ -86,14 +86,6 @@ | |||
86 | 86 | ||
87 | <fieldset class="w500p inline"> | 87 | <fieldset class="w500p inline"> |
88 | <div class="row"> | 88 | <div class="row"> |
89 | {{ form_label(form.user.username) }} | ||
90 | {{ form_errors(form.user.username) }} | ||
91 | {{ form_widget(form.user.username) }} | ||
92 | </div> | ||
93 | </fieldset> | ||
94 | |||
95 | <fieldset class="w500p inline"> | ||
96 | <div class="row"> | ||
97 | {{ form_label(form.user.name) }} | 89 | {{ form_label(form.user.name) }} |
98 | {{ form_errors(form.user.name) }} | 90 | {{ form_errors(form.user.name) }} |
99 | {{ form_widget(form.user.name) }} | 91 | {{ form_widget(form.user.name) }} |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php index 11c86423..5030bcbd 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php | |||
@@ -27,7 +27,7 @@ class ConfigControllerTest extends WallabagTestCase | |||
27 | 27 | ||
28 | $this->assertCount(1, $crawler->filter('button[id=config_save]')); | 28 | $this->assertCount(1, $crawler->filter('button[id=config_save]')); |
29 | $this->assertCount(1, $crawler->filter('button[id=change_passwd_save]')); | 29 | $this->assertCount(1, $crawler->filter('button[id=change_passwd_save]')); |
30 | $this->assertCount(1, $crawler->filter('button[id=user_save]')); | 30 | $this->assertCount(1, $crawler->filter('button[id=update_user_save]')); |
31 | $this->assertCount(1, $crawler->filter('button[id=new_user_save]')); | 31 | $this->assertCount(1, $crawler->filter('button[id=new_user_save]')); |
32 | $this->assertCount(1, $crawler->filter('button[id=rss_config_save]')); | 32 | $this->assertCount(1, $crawler->filter('button[id=rss_config_save]')); |
33 | } | 33 | } |
@@ -189,25 +189,15 @@ class ConfigControllerTest extends WallabagTestCase | |||
189 | return array( | 189 | return array( |
190 | array( | 190 | array( |
191 | array( | 191 | array( |
192 | 'user[username]' => '', | 192 | 'update_user[name]' => '', |
193 | 'user[name]' => '', | 193 | 'update_user[email]' => '', |
194 | 'user[email]' => '', | ||
195 | ), | 194 | ), |
196 | 'This value should not be blank.', | 195 | 'This value should not be blank.', |
197 | ), | 196 | ), |
198 | array( | 197 | array( |
199 | array( | 198 | array( |
200 | 'user[username]' => 'ad', | 199 | 'update_user[name]' => '', |
201 | 'user[name]' => '', | 200 | 'update_user[email]' => 'test', |
202 | 'user[email]' => '', | ||
203 | ), | ||
204 | 'This value is too short.', | ||
205 | ), | ||
206 | array( | ||
207 | array( | ||
208 | 'user[username]' => 'admin', | ||
209 | 'user[name]' => '', | ||
210 | 'user[email]' => 'test', | ||
211 | ), | 201 | ), |
212 | 'This value is not a valid email address.', | 202 | 'This value is not a valid email address.', |
213 | ), | 203 | ), |
@@ -226,7 +216,7 @@ class ConfigControllerTest extends WallabagTestCase | |||
226 | 216 | ||
227 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 217 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
228 | 218 | ||
229 | $form = $crawler->filter('button[id=user_save]')->form(); | 219 | $form = $crawler->filter('button[id=update_user_save]')->form(); |
230 | 220 | ||
231 | $crawler = $client->submit($form, $data); | 221 | $crawler = $client->submit($form, $data); |
232 | 222 | ||
@@ -245,12 +235,11 @@ class ConfigControllerTest extends WallabagTestCase | |||
245 | 235 | ||
246 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 236 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
247 | 237 | ||
248 | $form = $crawler->filter('button[id=user_save]')->form(); | 238 | $form = $crawler->filter('button[id=update_user_save]')->form(); |
249 | 239 | ||
250 | $data = array( | 240 | $data = array( |
251 | 'user[username]' => 'admin', | 241 | 'update_user[name]' => 'new name', |
252 | 'user[name]' => 'new name', | 242 | 'update_user[email]' => 'admin@wallabag.io', |
253 | 'user[email]' => 'admin@wallabag.io', | ||
254 | ); | 243 | ); |
255 | 244 | ||
256 | $client->submit($form, $data); | 245 | $client->submit($form, $data); |
@@ -298,6 +287,14 @@ class ConfigControllerTest extends WallabagTestCase | |||
298 | ), | 287 | ), |
299 | 'Password should by at least', | 288 | 'Password should by at least', |
300 | ), | 289 | ), |
290 | array( | ||
291 | array( | ||
292 | 'new_user[username]' => 'admin', | ||
293 | 'new_user[password]' => 'wallacewallace', | ||
294 | 'new_user[email]' => 'wallace@wallace.me', | ||
295 | ), | ||
296 | 'This value is already used', | ||
297 | ), | ||
301 | ); | 298 | ); |
302 | } | 299 | } |
303 | 300 | ||