Skip to content

Commit

Permalink
Merge pull request #11 from Flowpack/bugfix/account-is-null
Browse files Browse the repository at this point in the history
BUGFIX: Prevent error when security context is initialised but no account is active
  • Loading branch information
batabana authored Apr 18, 2023
2 parents 1528dac + 426a907 commit 43cb72b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Classes/PrunnerApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ public function apiCall(string $method, string $subpath, ?string $body): Respons

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

0 comments on commit 43cb72b

Please sign in to comment.