diff --git a/src/Authorization/Controller/LoginController.php b/src/Authorization/Controller/LoginController.php index 740fac0a3..2d31bcff6 100644 --- a/src/Authorization/Controller/LoginController.php +++ b/src/Authorization/Controller/LoginController.php @@ -20,11 +20,11 @@ use OpenApi\Attributes\Post; use Pimcore\Bundle\StudioBackendBundle\Authorization\Attributes\Request\CredentialsRequestBody; use Pimcore\Bundle\StudioBackendBundle\Authorization\Attributes\Response\InvalidCredentialsResponse; -use Pimcore\Bundle\StudioBackendBundle\Authorization\Schema\UserInformation; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Schema\UserInformation; use Pimcore\Security\User\User; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; diff --git a/src/Authorization/Schema/UserInformation.php b/src/OpenApi/Schema/UserInformation.php similarity index 87% rename from src/Authorization/Schema/UserInformation.php rename to src/OpenApi/Schema/UserInformation.php index c5a6d3972..11ebeea05 100644 --- a/src/Authorization/Schema/UserInformation.php +++ b/src/OpenApi/Schema/UserInformation.php @@ -14,7 +14,7 @@ * @license http://www.pimcore.org/license GPLv3 and PCL */ -namespace Pimcore\Bundle\StudioBackendBundle\Authorization\Schema; +namespace Pimcore\Bundle\StudioBackendBundle\OpenApi\Schema; use OpenApi\Attributes\Items; use OpenApi\Attributes\Property; @@ -24,8 +24,8 @@ * @internal */ #[Schema( - title: 'Login Success', - description: 'Login Success Response Schema for Pimcore Admin', + title: 'User Informations', + description: 'Informations about the user with username and roles', required: ['username', 'roles'], type: 'object' )] diff --git a/src/Authorization/Controller/CurrentUserController.php b/src/User/Controller/CurrentUserController.php similarity index 74% rename from src/Authorization/Controller/CurrentUserController.php rename to src/User/Controller/CurrentUserController.php index c6b251ca5..2afe63732 100644 --- a/src/Authorization/Controller/CurrentUserController.php +++ b/src/User/Controller/CurrentUserController.php @@ -14,15 +14,16 @@ * @license http://www.pimcore.org/license GPLv3 and PCL */ -namespace Pimcore\Bundle\StudioBackendBundle\Authorization\Controller; +namespace Pimcore\Bundle\StudioBackendBundle\User\Controller; use OpenApi\Attributes\Get; use OpenApi\Attributes\JsonContent; -use Pimcore\Bundle\StudioBackendBundle\Authorization\Schema\UserInformation; use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; +use Pimcore\Bundle\StudioBackendBundle\OpenApi\Schema\UserInformation; +use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; use Pimcore\Security\User\User; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; @@ -33,18 +34,20 @@ */ final class CurrentUserController extends AbstractApiController { - #[Route('/current-user', name: 'pimcore_studio_api_current_user', methods: ['GET'])] + #[Route('/user/current-user-information', name: 'pimcore_studio_api_current_user', methods: ['GET'])] #[Get( - path: self::API_PATH . '/current-user', - operationId: 'current-user', + path: self::API_PATH . '/user/current-user-information', + operationId: 'current-user-information', summary: 'Retrieve informations about the current logged in user.', - tags: [Tags::Authorization->name] + tags: [Tags::User->value] )] #[SuccessResponse( description: 'Current user informations.', content: new JsonContent(ref: UserInformation::class) )] - #[DefaultResponses] + #[DefaultResponses([ + HttpResponseCodes::UNAUTHORIZED + ])] public function login(#[CurrentUser] User $user): JsonResponse { return $this->jsonResponse([