Skip to content
This repository was archived by the owner on Apr 3, 2023. It is now read-only.

Commit b2b9718

Browse files
author
Teddy Roncin
committed
🐛 (Small bugs) Fixed 3 bugs
UserDataVisibilityItemDataProvider was crashing when trying to provide data to a non-authenticated user. PATCH /users/{id} didn't have the skip_null_values parameter set to false. On creation, UserInfos::$birthday was not set to a round day (it was set to the current time, not the current day)
1 parent d449038 commit b2b9718

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/DataProvider/UserDataVisibilityItemDataProvider.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
4040
return null;
4141
}
4242

43+
if (!$userLogged) {
44+
// We don't want to return null because it would return a 404
45+
return new User();
46+
}
47+
4348
/** @var UserAddress $address */
4449
foreach ($userToShow->getAddresses()->getValues() as $address) {
4550
if (!$this->canAccessInfo($userToShow, $address->getAddressVisibility(), $userLogged)) {

src/Entity/User.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@
6060
security: "is_granted('ROLE_ADMIN')",
6161
),
6262
new Patch(
63-
normalizationContext: ['groups' => ['user:read:one']],
63+
normalizationContext: [
64+
'groups' => ['user:read:one'],
65+
'skip_null_values' => false,
66+
],
6467
denormalizationContext: ['groups' => ['user:write:update']],
6568
security: "object == user or is_granted('ROLE_ADMIN')",
6669
),

src/Entity/UserInfos.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function __construct()
158158
{
159159
// Default values
160160
$this->setSex('Autre');
161-
$this->setBirthday(new \DateTime());
161+
$this->setBirthday((new \DateTime())->setTime(0, 0));
162162
$this->setAvatar('/default_user_avatar.png');
163163

164164
$this->sexVisibility = new ArrayCollection();

0 commit comments

Comments
 (0)