Fixed an error that prevented to create a new user.

Also added some validation constraints.
This commit is contained in:
Jan Böhmer 2019-09-11 19:04:09 +02:00
parent 90d449ea22
commit 0dd20394cb
2 changed files with 9 additions and 7 deletions

View file

@ -33,17 +33,15 @@ namespace App\Controller;
use App\Controller\AdminPages\BaseAdminController; use App\Controller\AdminPages\BaseAdminController;
use App\Entity\Parts\Category;
use App\Entity\UserSystem\Group; use App\Entity\UserSystem\Group;
use App\Form\AdminPages\CategoryAdminForm;
use App\Form\AdminPages\GroupAdminForm; use App\Form\AdminPages\GroupAdminForm;
use App\Services\EntityExporter; use App\Services\EntityExporter;
use App\Services\EntityImporter; use App\Services\EntityImporter;
use App\Services\StructuralElementRecursionHelper; use App\Services\StructuralElementRecursionHelper;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
/** /**
* @Route("/group") * @Route("/group")

View file

@ -66,6 +66,7 @@ use App\Security\Interfaces\HasPermissionsInterface;
use App\Validator\Constraints\Selectable; use App\Validator\Constraints\Selectable;
use App\Validator\Constraints\ValidPermission; use App\Validator\Constraints\ValidPermission;
use Doctrine\ORM\Mapping as ORM; 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\UserInterface;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
@ -75,6 +76,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* *
* @ORM\Entity(repositoryClass="App\Repository\UserRepository") * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
* @ORM\Table("`users`") * @ORM\Table("`users`")
* @UniqueEntity("name", message="validator.user.username_already_used")
*/ */
class User extends NamedDBElement implements UserInterface, HasPermissionsInterface class User extends NamedDBElement implements UserInterface, HasPermissionsInterface
{ {
@ -139,12 +141,14 @@ class User extends NamedDBElement implements UserInterface, HasPermissionsInterf
/** /**
* @var string|null The language/locale the user prefers * @var string|null The language/locale the user prefers
* @ORM\Column(type="string", name="config_language", nullable=true) * @ORM\Column(type="string", name="config_language", nullable=true)
* @Assert\Locale(canonicalize=true)
*/ */
protected $language = ''; protected $language = '';
/** /**
* @var string|null The timezone the user prefers * @var string|null The timezone the user prefers
* @ORM\Column(type="string", name="config_timezone", nullable=true) * @ORM\Column(type="string", name="config_timezone", nullable=true)
* @Assert\Timezone()
*/ */
protected $timezone = ''; protected $timezone = '';
@ -171,22 +175,22 @@ class User extends NamedDBElement implements UserInterface, HasPermissionsInterf
/** /**
* @ORM\Column(type="string", name="config_currency") * @ORM\Column(type="string", name="config_currency")
*/ */
protected $currency; protected $currency = "";
/** /**
* @ORM\Column(type="text", name="config_image_path") * @ORM\Column(type="text", name="config_image_path")
*/ */
protected $image_path; protected $image_path = "";
/** /**
* @ORM\Column(type="text", name="config_instock_comment_w") * @ORM\Column(type="text", name="config_instock_comment_w")
*/ */
protected $instock_comment_w; protected $instock_comment_w = "";
/** /**
* @ORM\Column(type="text", name="config_instock_comment_a") * @ORM\Column(type="text", name="config_instock_comment_a")
*/ */
protected $instock_comment_a; protected $instock_comment_a = "";
public function __construct() public function __construct()
{ {