From a340ba041a58ac027c6b6f7626ea408d79d663ac Mon Sep 17 00:00:00 2001 From: dylan_DPC Date: Sat, 23 Sep 2017 20:43:05 +0530 Subject: [PATCH] config fixes matches function fixed --- src/HMacValidator.php | 2 +- src/NonceGenerator.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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