Debug
This commit is contained in:
@ -439,18 +439,28 @@ class Toku extends Ideal\Service
|
|||||||
->from('toku_webhooks')
|
->from('toku_webhooks')
|
||||||
->where('enabled = ? AND JSON_SEARCH(events, "one", ?) IS NOT NULL');
|
->where('enabled = ? AND JSON_SEARCH(events, "one", ?) IS NOT NULL');
|
||||||
$params = [true, $eventType];
|
$params = [true, $eventType];
|
||||||
$this->logger->debug($query, $params);
|
|
||||||
$statement = $this->connection->prepare($query);
|
$statement = $this->connection->prepare($query);
|
||||||
$statement->execute($params);
|
$statement->execute($params);
|
||||||
$results = $statement->fetchAll(PDO::FETCH_COLUMN);
|
$results = $statement->fetchAll(PDO::FETCH_COLUMN);
|
||||||
$this->logger->debug('Results', $results);
|
|
||||||
if (count($results) === 0) {
|
if (count($results) === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_any($results, fn($secret) => HMAC::validate($timestamp, $signature, $eventId, $secret))) {
|
foreach ($results as $secret) {
|
||||||
|
if (HMAC::validate($timestamp, $signature, $eventId, $secret)) {
|
||||||
|
$this->logger->info('Toku webhook validated', [
|
||||||
|
'timestamp' => $timestamp,
|
||||||
|
'signature' => $signature,
|
||||||
|
'eventId' => $eventId,
|
||||||
|
'eventType' => $eventType,
|
||||||
|
'secret' => $secret,
|
||||||
|
]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
/*if (array_any($results, fn($secret) => HMAC::validate($timestamp, $signature, $eventId, $secret))) {
|
||||||
|
return true;
|
||||||
|
}*/
|
||||||
|
|
||||||
} catch (Throwable $throwable) {
|
} catch (Throwable $throwable) {
|
||||||
$this->logger->error($throwable);
|
$this->logger->error($throwable);
|
||||||
|
Reference in New Issue
Block a user