diff --git a/src/HMacValidator.php b/src/HMacValidator.php index 7851be4..ce3c297 100644 --- a/src/HMacValidator.php +++ b/src/HMacValidator.php @@ -27,7 +27,7 @@ protected function prepareParams(array $params) protected function validate(array $params, $hmac): bool { $paramString = http_build_query($params); - $hash = hash_hmac('sha256', $paramString, config('nonce.secret')); + $hash = hash_hmac('sha256', $paramString, config('validator.secret')); return hash_equals($hmac, $hash); } diff --git a/src/NonceGenerator.php b/src/NonceGenerator.php index aa935e4..ad14ae7 100644 --- a/src/NonceGenerator.php +++ b/src/NonceGenerator.php @@ -16,12 +16,16 @@ public function generate(Model $content): string public function store(Model $content, string $nonce): void { $content->update([ - config('nonce.key') => $nonce, + config('validator.key') => $nonce, ]); } public function matches(Model $content, string $nonce): bool { - return $nonce && data_get($content, $nonce) === $nonce; + $stored = data_get($content, config('validator.key')); + if(!$stored) { + throw new KeyNotFoundException(); + } + return $nonce && $stored === $nonce; } } \ No newline at end of file