From c45cd6347a8d453b3bf3441539faad5930109ad0 Mon Sep 17 00:00:00 2001 From: Juan Antonio Tubio Date: Wed, 11 Oct 2017 16:02:26 +0200 Subject: [PATCH 1/4] Added more info on route or method not allowed exception --- src/Pecee/SimpleRouter/Router.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Pecee/SimpleRouter/Router.php b/src/Pecee/SimpleRouter/Router.php index a80073b..d339952 100644 --- a/src/Pecee/SimpleRouter/Router.php +++ b/src/Pecee/SimpleRouter/Router.php @@ -285,7 +285,8 @@ class Router } if ($routeNotAllowed === true) { - $this->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 +} From eb63a5d6ba842590fc0d537d91b530feae5da501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sessing=C3=B8?= Date: Mon, 23 Oct 2017 22:01:19 +0200 Subject: [PATCH 2/4] Added CSRF form-example in documentation (issue: #299) --- README.md | 14 ++++++++++++++ src/Pecee/Http/Middleware/BaseCsrfVerifier.php | 1 + 2 files changed, 15 insertions(+) diff --git a/README.md b/README.md index edfab1d..509c799 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 and add a hidden field with the name of `csrf_token`. + +```php +
+ + +
+``` + --- # 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 @@ Date: Mon, 23 Oct 2017 22:04:28 +0200 Subject: [PATCH 3/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 509c799..f8471ca 100644 --- a/README.md +++ b/README.md @@ -714,7 +714,7 @@ You can change the key by overwriting the constant in your own CSRF-verifier cla **Example:** -The example below will post to the current url and add a hidden field with the name of `csrf_token`. +The example below will post to the current url with a hidden field "`csrf_token`". ```php
From cc5e417db9779b357effd6ae770e0e9f0df7b5a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sessing=C3=B8?= Date: Mon, 23 Oct 2017 22:05:27 +0200 Subject: [PATCH 4/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8471ca..7817f6a 100644 --- a/README.md +++ b/README.md @@ -716,7 +716,7 @@ You can change the key by overwriting the constant in your own CSRF-verifier cla The example below will post to the current url with a hidden field "`csrf_token`". -```php +```html