ADd user response for login
dyb-tech.com/LaLiga-BackEnd/pipeline/head This commit looks good Details

This commit is contained in:
Daniel Guzman 2024-05-23 00:41:50 +02:00
parent 85d597c679
commit cc7c707445
2 changed files with 28 additions and 5 deletions

View File

@ -17,14 +17,14 @@ class UserDto
public \DateTimeInterface $birthday; public \DateTimeInterface $birthday;
public array $noteList; public array $noteList;
public bool $active; public bool $active;
public array $notificationDtoList; public array $receivedNotificationDtoList;
public array $validationErrors; public array $validationErrors;
public function toArray(): array public function toArray(): array
{ {
if (!empty($this->notificationDtoList)) if (!empty($this->receivedNotificationDtoList))
{ {
foreach ($this->notificationDtoList as $notificationDto) foreach ($this->receivedNotificationDtoList as $notificationDto)
{ {
$notificationArray[] = $notificationDto->toArray(); $notificationArray[] = $notificationDto->toArray();
} }
@ -42,6 +42,20 @@ class UserDto
]; ];
} }
public function toLoginArray(): array
{
return [
'id' => $this->id ?? null,
'email' => $this->email ?? null,
'firstName' => $this->firstName ?? null,
'lastName' => $this->lastName ?? null,
'phone' => $this->phone,
'profilePicture' => $this->profilePicture ?? null,
'birthday' => $this->birthday->format('Y-m-d'),
'unreadNotifications' => count($this->receivedNotificationDtoList)
];
}
public function toRegisterArray(): array public function toRegisterArray(): array
{ {
return [ return [
@ -85,6 +99,15 @@ class UserDto
{ {
$this->birthday = $userObj->getBirthday(); $this->birthday = $userObj->getBirthday();
} }
if ($userObj->getReceivedNotifications() !== null)
{
foreach ($userObj->getReceivedNotifications() as $receivedNotificationEntity)
{
$notificationDto = new NotificationDto();
$notificationDto->fillFromObj($receivedNotificationEntity);
$this->receivedNotificationDtoList[] = $notificationDto;
}
}
if ($userObj->getNoteList() !== null) if ($userObj->getNoteList() !== null)
{ {
$this->noteList = $userObj->getNoteList(); $this->noteList = $userObj->getNoteList();

View File

@ -31,11 +31,11 @@ class AuthenticationSuccessListener
$notificationDtoList[] = $notificationDto; $notificationDtoList[] = $notificationDto;
} }
} }
$userDto->notificationDtoList = $notificationDtoList; $userDto->receivedNotificationDtoList = $notificationDtoList;
$userDto->fillFromObject($user); $userDto->fillFromObject($user);
$expirationDateTime = (new \DateTime('now', new \DateTimeZone('Europe/Madrid')))->modify('+1800 seconds'); $expirationDateTime = (new \DateTime('now', new \DateTimeZone('Europe/Madrid')))->modify('+1800 seconds');
$data['expirationDateTime'] = $expirationDateTime->format('Y-m-d H:i:s'); $data['expirationDateTime'] = $expirationDateTime->format('Y-m-d H:i:s');
$data['user'] = $userDto->toArray(); $data['user'] = $userDto->toLoginArray();
$event->setData($data); $event->setData($data);
} }