diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index dbae3ea73..898c291f2 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php @@ -9,7 +9,7 @@ use Symfony\Component\HttpFoundation\JsonResponse; 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; @@ -65,7 +65,7 @@ class ConfigController extends Controller } // handle changing user information - $userForm = $this->createForm(new UserType(), $user); + $userForm = $this->createForm(new UserInformationType(), $user); $userForm->handleRequest($request); if ($userForm->isValid()) { diff --git a/src/Wallabag/CoreBundle/Entity/User.php b/src/Wallabag/CoreBundle/Entity/User.php index e75e3a837..63ec072c8 100644 --- a/src/Wallabag/CoreBundle/Entity/User.php +++ b/src/Wallabag/CoreBundle/Entity/User.php @@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Entity; 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; @@ -17,6 +18,9 @@ use JMS\Serializer\Annotation\Expose; * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\UserRepository") * @ORM\HasLifecycleCallbacks() * @ExclusionPolicy("all") + * + * @UniqueEntity("email") + * @UniqueEntity("username") */ class User implements AdvancedUserInterface, \Serializable { diff --git a/src/Wallabag/CoreBundle/Form/Type/UserType.php b/src/Wallabag/CoreBundle/Form/Type/UserInformationType.php similarity index 87% rename from src/Wallabag/CoreBundle/Form/Type/UserType.php rename to src/Wallabag/CoreBundle/Form/Type/UserInformationType.php index b479a0b58..617722dbf 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; 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 - ->add('username', 'text') ->add('name', 'text') ->add('email', 'text') ->add('save', 'submit') @@ -26,6 +25,6 @@ class UserType extends AbstractType public function getName() { - return 'user'; + return 'update_user'; } } diff --git a/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig index f2a98dfbf..c90bb2e3b 100644 --- a/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/Config/index.html.twig @@ -84,14 +84,6 @@