refs #379. Add validation in User CRUD
parent
67db747d4c
commit
2a2c2bcfe0
|
@ -21,7 +21,7 @@ resources:
|
||||||
ApiPlatform\Metadata\Patch:
|
ApiPlatform\Metadata\Patch:
|
||||||
provider: App\State\Provider\UserProvider
|
provider: App\State\Provider\UserProvider
|
||||||
ApiPlatform\Metadata\Post:
|
ApiPlatform\Metadata\Post:
|
||||||
validation_context:
|
validationContext:
|
||||||
groups: [ 'default', 'user:post' ]
|
groups: [ 'default', 'user:post' ]
|
||||||
ApiPlatform\Metadata\Delete: ~
|
ApiPlatform\Metadata\Delete: ~
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ final class UserGroupInput
|
||||||
public ?string $name = null;
|
public ?string $name = null;
|
||||||
|
|
||||||
#[Groups(['user-group:write'])]
|
#[Groups(['user-group:write'])]
|
||||||
public array $permissions = [];
|
public ?array $permissions = [];
|
||||||
|
|
||||||
#[Assert\NotNull]
|
#[Assert\NotNull]
|
||||||
#[Groups(['user-group:write'])]
|
#[Groups(['user-group:write'])]
|
||||||
|
|
|
@ -23,8 +23,8 @@ final class UserInput
|
||||||
#[Groups(['user:write'])]
|
#[Groups(['user:write'])]
|
||||||
public array $allowedOrganizationalUnits = [];
|
public array $allowedOrganizationalUnits = [];
|
||||||
|
|
||||||
#[Assert\NotBlank(groups: ['user:create'])]
|
#[Assert\NotBlank(groups: ['user:post'])]
|
||||||
#[Assert\Length(min: 8)]
|
#[Assert\Length(min: 8, groups: ['user:write', 'user:post'])]
|
||||||
#[Groups(['user:write'])]
|
#[Groups(['user:write'])]
|
||||||
public ?string $password = null;
|
public ?string $password = null;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ final class UserOutput extends AbstractOutput
|
||||||
public bool $enabled;
|
public bool $enabled;
|
||||||
#[Groups(['user:read'])]
|
#[Groups(['user:read'])]
|
||||||
public array $allowedOrganizationalUnits;
|
public array $allowedOrganizationalUnits;
|
||||||
|
#[Groups(['user:read'])]
|
||||||
|
public array $userGroups;
|
||||||
|
|
||||||
#[Groups(['user:read'])]
|
#[Groups(['user:read'])]
|
||||||
public \DateTime $createAt;
|
public \DateTime $createAt;
|
||||||
|
@ -33,6 +35,7 @@ final class UserOutput extends AbstractOutput
|
||||||
$this->username = $user->getUsername();
|
$this->username = $user->getUsername();
|
||||||
$this->roles = $user->getRoles();
|
$this->roles = $user->getRoles();
|
||||||
$this->enabled = $user->isEnabled();
|
$this->enabled = $user->isEnabled();
|
||||||
|
$this->userGroups = $user->getUserGroups()->toArray();
|
||||||
$this->allowedOrganizationalUnits = $user->getAllowedOrganizationalUnits()->toArray();
|
$this->allowedOrganizationalUnits = $user->getAllowedOrganizationalUnits()->toArray();
|
||||||
$this->createAt = $user->getCreatedAt();
|
$this->createAt = $user->getCreatedAt();
|
||||||
$this->createBy = $user->getCreatedBy();
|
$this->createBy = $user->getCreatedBy();
|
||||||
|
|
Loading…
Reference in New Issue