Skip to content

Commit

Permalink
add(api): #44 - added /meroute
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelbelolo committed Oct 6, 2022
1 parent dcbaa06 commit 2f4b05f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/src/Controller/Api/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
#[Route('/api/users', name: 'api_user_')]
class UserController extends AbstractController
{
#[Route('/me', name: 'me', methods: ['GET'])]
public function meAction(Request $request): JsonResponse
{
/** @var User $user */
$user = $this->getUser();

return $this->json($user->toArray(), Response::HTTP_OK);
}

#[Route('/email', name: 'request_update_email', methods: ['PATCH'])]
public function requestEmailUpdate(Request $request, DocumentManager $dm, Validator $validator, MailerInterface $mailer): JsonResponse
{
Expand Down
7 changes: 7 additions & 0 deletions api/src/Document/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,11 @@ public function setToken(?string $token): void
{
$this->token = $token;
}

public function toArray(): array
{
return [
'email' => $this->email,
];
}
}

0 comments on commit 2f4b05f

Please sign in to comment.