feat: require an api key to schedule
This commit is contained in:
@@ -61,3 +61,16 @@ function error_out(string $message, int $status = 400): never
|
||||
{
|
||||
json_out(['error' => $message], $status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aborts with 400 if no Clickatell API key has been configured.
|
||||
*/
|
||||
function require_api_key(): void
|
||||
{
|
||||
$stmt = db()->prepare("SELECT setting_value FROM `system` WHERE setting_name = 'clickatell_api_key'");
|
||||
$stmt->execute();
|
||||
$key = $stmt->fetchColumn();
|
||||
if ($key === false || trim((string) $key) === '') {
|
||||
error_out('No Clickatell API key is configured. Set one in Admin → Clickatell Settings before sending or scheduling messages.', 400);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user