From d27fd3eb33616937ff2415b7d9be7a9b1075f32e Mon Sep 17 00:00:00 2001 From: Jonathan Lelievre Date: Thu, 6 Jun 2024 16:47:29 +0200 Subject: [PATCH 1/2] Remove uselss methods from ol user interface --- src/Core/Security/OAuth2/JwtTokenUser.php | 5 ----- src/PrestaShopBundle/Entity/ApiClient.php | 5 ----- .../Security/OAuth2/Provider/ApiClientProvider.php | 5 ----- .../Service/DataProvider/UserProvider.php | 12 ------------ 4 files changed, 27 deletions(-) diff --git a/src/Core/Security/OAuth2/JwtTokenUser.php b/src/Core/Security/OAuth2/JwtTokenUser.php index 99ff651e68102..8235c6488e3a9 100644 --- a/src/Core/Security/OAuth2/JwtTokenUser.php +++ b/src/Core/Security/OAuth2/JwtTokenUser.php @@ -64,11 +64,6 @@ public function eraseCredentials() return; } - public function getUsername() - { - return ''; - } - public function getUserIdentifier(): string { return $this->userId; diff --git a/src/PrestaShopBundle/Entity/ApiClient.php b/src/PrestaShopBundle/Entity/ApiClient.php index 92cff511355d0..8d831e5fda4a7 100644 --- a/src/PrestaShopBundle/Entity/ApiClient.php +++ b/src/PrestaShopBundle/Entity/ApiClient.php @@ -232,11 +232,6 @@ public function eraseCredentials(): void { } - public function getUsername(): string - { - return $this->getClientName(); - } - public function getUserIdentifier(): string { return $this->getClientId(); diff --git a/src/PrestaShopBundle/Security/OAuth2/Provider/ApiClientProvider.php b/src/PrestaShopBundle/Security/OAuth2/Provider/ApiClientProvider.php index 87aafa160db3b..736a0c0d03454 100644 --- a/src/PrestaShopBundle/Security/OAuth2/Provider/ApiClientProvider.php +++ b/src/PrestaShopBundle/Security/OAuth2/Provider/ApiClientProvider.php @@ -69,9 +69,4 @@ public function supportsClass(string $class): bool { return $class === ApiClient::class; } - - public function loadUserByUsername(string $username): ApiClient - { - return $this->loadUserByIdentifier($username); - } } diff --git a/src/PrestaShopBundle/Service/DataProvider/UserProvider.php b/src/PrestaShopBundle/Service/DataProvider/UserProvider.php index a17fe51334d38..9509996a8de6b 100644 --- a/src/PrestaShopBundle/Service/DataProvider/UserProvider.php +++ b/src/PrestaShopBundle/Service/DataProvider/UserProvider.php @@ -36,8 +36,6 @@ */ class UserProvider { - public const ANONYMOUS_USER = 'ANONYMOUS_USER'; - public function __construct( private readonly Security $security, ) { @@ -56,16 +54,6 @@ public function getUser(): ?UserInterface return null; } - public function getUsername(): string - { - $user = $this->getUser(); - if ($user instanceof UserInterface) { - return $user->getUserIdentifier(); - } - - return self::ANONYMOUS_USER; - } - public function logout(): void { $this->security->logout(false); From 9c48b3f7e18706acefab6e0f3ac8ae45fcea7ec0 Mon Sep 17 00:00:00 2001 From: Jonathan Lelievre Date: Thu, 6 Jun 2024 16:49:15 +0200 Subject: [PATCH 2/2] Add readonly in LegacyControllerContext --- src/Core/Context/LegacyControllerContext.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Core/Context/LegacyControllerContext.php b/src/Core/Context/LegacyControllerContext.php index 787a6ddf2c756..9870e005f7d2d 100644 --- a/src/Core/Context/LegacyControllerContext.php +++ b/src/Core/Context/LegacyControllerContext.php @@ -111,20 +111,18 @@ class LegacyControllerContext * @param string|null $token Legacy security token * @param string $override_folder * @param string $currentIndex Legacy current index built like a legacy URL based on controller name - * - * @todo Add a readonly tag to fields when switching to symfony 6.2, currently an error does not allow this to be done (see https://github.com/FriendsOfPHP/proxy-manager-lts/issues/26) */ public function __construct( protected readonly ContainerInterface $container, - public string $controller_name, - public string $controller_type, - public int $multishop_context, - public ?string $className, - public int $id, - public ?string $token, - public string $override_folder, - public string $currentIndex, - public string $table, + public readonly string $controller_name, + public readonly string $controller_type, + public readonly int $multishop_context, + public readonly ?string $className, + public readonly int $id, + public readonly ?string $token, + public readonly string $override_folder, + public readonly string $currentIndex, + public readonly string $table, ) { $this->php_self = $this->controller_name; }