refs #379. Allow_extra_attributes false

pull/5/head
Manuel Aranda Rosales 2024-05-30 11:43:48 +02:00
parent 8d3c3c195c
commit e1d782c8a0
3 changed files with 6 additions and 3 deletions

View File

@ -7,6 +7,7 @@ resources:
groups: ['default', 'user:read']
denormalization_context:
groups: ['user:write']
operations:
ApiPlatform\Metadata\GetCollection:
provider: App\State\Provider\UserProvider

View File

@ -11,6 +11,8 @@ api_platform:
paths: ['%kernel.project_dir%/config/api_platform', '%kernel.project_dir%/src/Dto']
defaults:
pagination_client_items_per_page: true
denormalization_context:
allow_extra_attributes: false
cache_headers:
vary: [ 'Content-Type', 'Authorization', 'Origin' ]
extra_properties:

View File

@ -48,12 +48,12 @@ class UserProcessor implements ProcessorInterface
throw new \Exception(sprintf('data is not instance of %s', UserInput::class));
}
$entity = null;
$user = null;
if (isset($uriVariables['uuid'])) {
$entity = $this->userRepository->findOneByUuid($uriVariables['uuid']);
$user = $this->userRepository->findOneByUuid($uriVariables['uuid']);
}
$user = $data->createOrUpdateEntity($entity);
$user = $data->createOrUpdateEntity($user);
if ($data->password !== null){
$user->setPassword($this->userPasswordHasher->hashPassword($user, $data->password));