Skip to content

Commit

Permalink
Move current user request to user Section.
Browse files Browse the repository at this point in the history
  • Loading branch information
martineiber committed Jun 10, 2024
1 parent f91540e commit 3756a7f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Authorization/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'
)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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([
Expand Down

0 comments on commit 3756a7f

Please sign in to comment.