getEntityManager()->getRepository('User')->findOne([ 'whereClause' => [ 'type' => 'api', 'apiKey' => $apiKey, 'authMethod' => 'Hmac' ] ]); if (!$user) return; if ($user) { $apiKeyUtil = new \Espo\Core\Utils\ApiKey($this->getConfig()); $secretKey = $apiKeyUtil->getSecretKeyForUserId($user->id); if (!$secretKey) return; $string = $request->getMethod() . ' ' . $request->getResourceUri(); if ($hash === \Espo\Core\Utils\ApiKey::hash($secretKey, $string)) { return $user; } return; } return $user; } }