diff --git a/app/plugins/OrcidSource/src/Controller/ApiV2Controller.php b/app/plugins/OrcidSource/src/Controller/ApiV2Controller.php index 4d99c4b3c..22ff3307c 100644 --- a/app/plugins/OrcidSource/src/Controller/ApiV2Controller.php +++ b/app/plugins/OrcidSource/src/Controller/ApiV2Controller.php @@ -88,16 +88,10 @@ public function get(string $orcid, int $coId) { $orcidSourcesRecords = $this->OrcidSources ->find() ->contain([ - 'Servers.Oauth2Servers' => function ($q) { - return $q->where(["LOWER(Oauth2Servers.url) LIKE" => '%orcid%']); - }, + 'Servers', 'ExternalIdentitySources', ]) - ->innerJoinWith('Servers.Oauth2Servers', function ($q) { - return $q->where([ - "LOWER(Oauth2Servers.url) LIKE" => '%orcid%' - ]); - }) + ->innerJoinWith('Servers') ->innerJoinWith('ExternalIdentitySources') ->where([ 'Servers.plugin' => 'CoreServer.Oauth2Servers', diff --git a/app/plugins/OrcidSource/src/Model/Table/OrcidSourcesTable.php b/app/plugins/OrcidSource/src/Model/Table/OrcidSourcesTable.php index a72fa7a08..4bbb0052f 100644 --- a/app/plugins/OrcidSource/src/Model/Table/OrcidSourcesTable.php +++ b/app/plugins/OrcidSource/src/Model/Table/OrcidSourcesTable.php @@ -517,28 +517,22 @@ protected function orcidConnect( ): \Cake\Http\Client { $this->orcidSource = $this->find() ->contain([ - 'Servers.Oauth2Servers' => function ($q) { - return $q->where(["LOWER(Oauth2Servers.url) LIKE" => '%orcid%']); - }, + 'Servers' => ['Oauth2Servers'], 'ExternalIdentitySources', ]) - ->innerJoinWith('Servers.Oauth2Servers', function ($q) { - return $q->where([ - "LOWER(Oauth2Servers.url) LIKE" => '%orcid%' - ]); - }) + ->innerJoinWith('Servers.Oauth2Servers') ->innerJoinWith('ExternalIdentitySources') ->where([ 'Servers.plugin' => 'CoreServer.Oauth2Servers', 'ExternalIdentitySources.id' => $exterrnalIdentitySource->id, - 'ExternalIdentitySources.plugin' => 'OrcidSource.OrcidSources' + 'ExternalIdentitySources.plugin' => 'OrcidSource.OrcidSources', ]) ->first(); // Set the CO ID $this->setCurCoId($this->orcidSource->server->co_id); - if ( empty($this->orcidSource->id)) { + if (empty($this->orcidSource->id)) { throw new \InvalidArgumentException(__d('error', 'notfound', [__d('core_server', 'controller.Oauth2Servers')])); }