diff --git a/README.md b/README.md index edfab1d..7817f6a 100644 --- a/README.md +++ b/README.md @@ -709,6 +709,20 @@ You can get the CSRF-token by calling the helper method: csrf_token(); ``` +The default name/key for the input-field is `csrf_token` and is defined in the `POST_KEY` constant in the `BaseCsrfVerifier` class. +You can change the key by overwriting the constant in your own CSRF-verifier class. + +**Example:** + +The example below will post to the current url with a hidden field "`csrf_token`". + +```html +
+``` + --- # Middlewares diff --git a/src/Pecee/Http/Middleware/BaseCsrfVerifier.php b/src/Pecee/Http/Middleware/BaseCsrfVerifier.php index 5d2b4cf..6791029 100644 --- a/src/Pecee/Http/Middleware/BaseCsrfVerifier.php +++ b/src/Pecee/Http/Middleware/BaseCsrfVerifier.php @@ -1,4 +1,5 @@ handleException(new HttpException('Route or method not allowed', 403)); + $message = sprintf('Route "%s" or method "%s" not allowed.', $this->request->getUri()->getPath(), $this->request->getMethod()); + $this->handleException(new HttpException($message, 403)); } if ($this->request->getLoadedRoute() === null) { @@ -594,4 +595,4 @@ class Router return $this; } -} \ No newline at end of file +}