From 16353c3a8a9381ae0d07bec7693008294de53267 Mon Sep 17 00:00:00 2001 From: Aina Sitraka <35221835+aynsix@users.noreply.github.com> Date: Tue, 17 Oct 2023 23:00:29 +0300 Subject: [PATCH] PHRAS-3921 expose-cli oauth token uri compatibility v2 v3 and asset title set (#4392) * some fix * PHRAS-3936 set expose asset title with title define in Phraseanet --- .../PhraseanetService/Controller/PSExposeController.php | 2 +- .../Phrasea/WorkerManager/Worker/ExposeUploadWorker.php | 5 +++-- templates/web/admin/phraseanet-service/expose.html.twig | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Alchemy/Phrasea/PhraseanetService/Controller/PSExposeController.php b/lib/Alchemy/Phrasea/PhraseanetService/Controller/PSExposeController.php index b202679d40..63f4d25cac 100644 --- a/lib/Alchemy/Phrasea/PhraseanetService/Controller/PSExposeController.php +++ b/lib/Alchemy/Phrasea/PhraseanetService/Controller/PSExposeController.php @@ -1355,7 +1355,7 @@ private function getAndSaveToken($exposeName) $accessToken = $tokenInfo['access_token']; } elseif (is_array($tokenInfo) && $tokenInfo['expires_at'] > time()) { $accessToken = $tokenInfo['access_token']; - } elseif (is_array($tokenInfo) && $tokenInfo['expires_at'] <= time() && $tokenInfo['refresh_expires_at'] > time()) { + } elseif (is_array($tokenInfo) && $tokenInfo['expires_at'] <= time() && isset($tokenInfo['refresh_expires_at']) && $tokenInfo['refresh_expires_at'] > time()) { $resToken = $this->refreshToken($oauthClient, $config, $tokenInfo['refresh_token']); if ($resToken->getStatusCode() !== 200) { diff --git a/lib/Alchemy/Phrasea/WorkerManager/Worker/ExposeUploadWorker.php b/lib/Alchemy/Phrasea/WorkerManager/Worker/ExposeUploadWorker.php index 41bbd14188..bd72160259 100644 --- a/lib/Alchemy/Phrasea/WorkerManager/Worker/ExposeUploadWorker.php +++ b/lib/Alchemy/Phrasea/WorkerManager/Worker/ExposeUploadWorker.php @@ -225,6 +225,7 @@ public function process(array $payload) 'publication_id' => $payload['publicationId'], 'description' => $description, 'asset_id' => $assetId, + 'title' => $record->get_title(), 'upload' => [ 'type' => $record->get_subdef($phraseanetSubdefAsDocument)->get_mime(), 'size' => $record->get_subdef($phraseanetSubdefAsDocument)->get_size(), @@ -472,9 +473,9 @@ private function getToken() if ($this->exposeConfiguration['connection_kind'] == 'password') { if (!isset($this->accessTokenInfo['expires_at'])) { return $this->accessTokenInfo['access_token']; - } elseif ($this->accessTokenInfo['expires_at'] > time() && $this->accessTokenInfo['refresh_expires_at'] > time()) { + } elseif ($this->accessTokenInfo['expires_at'] > time()) { return $this->accessTokenInfo['access_token']; - } elseif ($this->accessTokenInfo['expires_at'] <= time() && $this->accessTokenInfo['refresh_expires_at'] > time()) { + } elseif ($this->accessTokenInfo['expires_at'] <= time() && isset($tokenInfo['refresh_expires_at']) && $this->accessTokenInfo['refresh_expires_at'] > time()) { $resToken = $oauthClient->post($this->exposeConfiguration['oauth_token_uri'], [ 'form_params' => [ 'client_id' => $this->exposeConfiguration['auth_client_id'], diff --git a/templates/web/admin/phraseanet-service/expose.html.twig b/templates/web/admin/phraseanet-service/expose.html.twig index c9750bc95f..18cfc39528 100644 --- a/templates/web/admin/phraseanet-service/expose.html.twig +++ b/templates/web/admin/phraseanet-service/expose.html.twig @@ -48,7 +48,7 @@ {{ form_row(form.expose_client_id) }} -