Skip to content

Commit

Permalink
config fixes
Browse files Browse the repository at this point in the history
matches function fixed
  • Loading branch information
Dylan-DPC committed Sep 23, 2017
1 parent 09fd8d1 commit a340ba0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/HMacValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
Expand Down
8 changes: 6 additions & 2 deletions src/NonceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit a340ba0

Please sign in to comment.