Skip to content

Commit 43cb72b

Browse files
authored
Merge pull request #11 from Flowpack/bugfix/account-is-null
BUGFIX: Prevent error when security context is initialised but no account is active
2 parents 1528dac + 426a907 commit 43cb72b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Classes/PrunnerApiService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ public function apiCall(string $method, string $subpath, ?string $body): Respons
114114

115115
// There are usecases where we want to call prunner from the CLI. We don't have an initialized user there, thus we
116116
// hardcode it to 'cli' in these cases. The account identifier in prunner is only used for e.g. log messages.
117-
$accountIdentifier = $this->context->isInitialized() ? $this->context->getAccount()->getAccountIdentifier() : 'cli';
117+
$account = $this->context->isInitialized() ? $this->context->getAccount() : null;
118+
$accountIdentifier = $account ? $account->getAccountIdentifier() : 'cli';
118119
// Generate JWT token on the fly with expiration in 60 seconds
119120
$authToken = JWT::encode(['sub' => $accountIdentifier, 'exp' => time() + 60], $jwtSecret, 'HS256');
120121
$client = new Client();

0 commit comments

Comments
 (0)