From afc100acb4930d6d698ab23bf30641b1b40f9006 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 23 Aug 2021 16:38:16 +0000 Subject: [PATCH] implement-basicbatchaction-getselect --- .../Civi/Api4/Action/OAuthSysToken/Refresh.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ext/oauth-client/Civi/Api4/Action/OAuthSysToken/Refresh.php b/ext/oauth-client/Civi/Api4/Action/OAuthSysToken/Refresh.php index 043a83b5d2a8..1daa8606169d 100644 --- a/ext/oauth-client/Civi/Api4/Action/OAuthSysToken/Refresh.php +++ b/ext/oauth-client/Civi/Api4/Action/OAuthSysToken/Refresh.php @@ -38,13 +38,19 @@ class Refresh extends BasicBatchAction { private $syncFields = ['access_token', 'refresh_token', 'expires', 'token_type']; private $writeFields = ['access_token', 'refresh_token', 'expires', 'token_type', 'raw']; + private $selectFields = ['id', 'client_id', 'access_token', 'refresh_token', 'expires', 'token_type', 'raw']; private $providers = []; public function __construct($entityName, $actionName) { - parent::__construct($entityName, $actionName, '*'); + parent::__construct($entityName, $actionName); + } + + protected function getSelect() { + return $this->selectFields; } protected function doTask($row) { + if ($this->threshold >= 0 && \CRM_Utils_Time::getTimeRaw() < $row['expires'] - $this->threshold) { return $this->filterReturn($row); } @@ -73,14 +79,17 @@ protected function doTask($row) { } protected function getProvider($clientId) { + if (!isset($this->providers[$clientId])) { $client = \Civi\Api4\OAuthClient::get(0)->addWhere('id', '=', $clientId)->execute()->single(); + $this->providers[$clientId] = \Civi::service('oauth2.league')->createProvider($client); } return $this->providers[$clientId]; } protected function filterReturn($tokenRecord) { + return $this->checkPermissions ? \CRM_OAuth_BAO_OAuthSysToken::redact($tokenRecord) : $tokenRecord; }