diff --git a/src/Pecee/Exception/TokenMismatchException.php b/src/Pecee/Exception/TokenMismatchException.php new file mode 100644 index 0000000..0a45962 --- /dev/null +++ b/src/Pecee/Exception/TokenMismatchException.php @@ -0,0 +1,4 @@ +csrfToken = new CsrfToken(); + } /** * Check if the url matches the urls in the except property @@ -52,9 +57,8 @@ class BaseCsrfVerifier extends Middleware { $token = $request->getHeader(self::HEADER_KEY); } - $tokenValidator = new CsrfToken(); - if( !$tokenValidator->validate( $token ) ) { - throw new RouterException('Invalid csrf-token.'); + if( !$this->csrfToken->validate( $token ) ) { + throw new TokenMismatchException('Invalid csrf-token.'); } }