diff --git a/src/Bundle/ChillMainBundle/Controller/UserApiController.php b/src/Bundle/ChillMainBundle/Controller/UserApiController.php index 6b583f546..3742a7ded 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserApiController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserApiController.php @@ -3,8 +3,25 @@ namespace Chill\MainBundle\Controller; use Chill\MainBundle\CRUD\Controller\ApiController; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\Routing\Annotation\Route; class UserApiController extends ApiController { + /** + * @Route( + * "/api/1.0/main/whoami.{_format}", + * name="chill_main_user_whoami", + * requirements={ + * "_format": "json" + * } + * ) + */ + public function whoami($_format): JsonResponse + { + return $this->json($this->getUser(), JsonResponse::HTTP_OK, [], + [ "groups" => [ "read" ] ]); + } } diff --git a/src/Bundle/ChillMainBundle/chill.api.specs.yaml b/src/Bundle/ChillMainBundle/chill.api.specs.yaml index e53900643..775407847 100644 --- a/src/Bundle/ChillMainBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillMainBundle/chill.api.specs.yaml @@ -448,6 +448,14 @@ paths: responses: 200: description: "ok" + /1.0/main/whoami.json: + get: + tags: + - user + summary: Return the currently authenticated user + responses: + 200: + description: "ok" /1.0/main/user/{id}.json: get: tags: