Skip to content

Commit bac0f15

Browse files
committed
TASK: add default account identifier for cli calls
1 parent 572559d commit bac0f15

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Classes/PrunnerApiService.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ public function apiCall(string $method, string $subpath, ?string $body): Respons
111111
throw new \RuntimeException('Invalid prunner configuration (could not read JWT secret)');
112112
}
113113
}
114-
$accountIdentifier = $this->context->getAccount()->getAccountIdentifier();
114+
115+
// There are usecases where we want to call prunner from the CLI. We don't have an initialized user there, thus we
116+
// 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';
115118
// Generate JWT token on the fly with expiration in 60 seconds
116119
$authToken = JWT::encode(['sub' => $accountIdentifier, 'exp' => time() + 60], $jwtSecret, 'HS256');
117120
$client = new Client();

0 commit comments

Comments
 (0)