Skip to content
Snippets Groups Projects
Commit fbe246f0 authored by Dimitris Spachos's avatar Dimitris Spachos Committed by Aaron Bauman
Browse files

Issue #3224747 by dspachos: isInit() crashes when JWT is deactivated

parent 75627c2b
No related branches found
No related tags found
No related merge requests found
Pipeline #96128 canceled
......@@ -195,8 +195,9 @@ class SalesforceJWTPlugin extends SalesforceAuthProviderPluginBase {
* JWT Assertion.
*/
protected function generateAssertion() {
$key = $this->keyRepository->getKey($this->getCredentials()->getKeyId())
->getKeyValue();
$key = $this->keyRepository->getKey($this->getCredentials()->getKeyId()) ?
$this->keyRepository->getKey($this->getCredentials()->getKeyId())
->getKeyValue() : '';
$token = $this->generateAssertionClaim();
return JWT::encode($token, $key, 'RS256');
}
......
......@@ -7,6 +7,7 @@ use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Logger\LoggerChannelTrait;
use Drupal\Core\State\StateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\salesforce\IdentityNotFoundException;
......@@ -25,6 +26,7 @@ use GuzzleHttp\Exception\RequestException;
class RestClient implements RestClientInterface {
use StringTranslationTrait;
use LoggerChannelTrait;
/**
* Response object.
......@@ -207,8 +209,14 @@ class RestClient implements RestClientInterface {
}
// If authToken is not set, try refreshing it before failing init.
if (!$this->authToken) {
$this->authToken = $this->authManager->refreshToken();
return isset($this->authToken);
try {
$this->authToken = $this->authManager->refreshToken();
return isset($this->authToken);
}
catch (\Exception $e) {
$this->getLogger('salesforce')->error('@e', ['@e' => $e->getMessage()]);
return FALSE;
}
}
return TRUE;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment