From 34196aa8ed4bac34781be85ff8f42c9d43166e64 Mon Sep 17 00:00:00 2001 From: DarkGhostHunter Date: Thu, 13 Jun 2019 00:15:54 -0400 Subject: [PATCH 1/2] Fixed variable string given by reCAPTCHA servers. --- src/Http/Middleware/CheckRecaptcha.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Http/Middleware/CheckRecaptcha.php b/src/Http/Middleware/CheckRecaptcha.php index ead9c95..55a416b 100644 --- a/src/Http/Middleware/CheckRecaptcha.php +++ b/src/Http/Middleware/CheckRecaptcha.php @@ -101,7 +101,7 @@ protected function isPostMethod(Request $request) protected function hasValidRequest(Request $request) { $isValid = !$this->validator->make($request->only('_recaptcha'), [ - '_recaptcha' => 'required|string|size:356', + '_recaptcha' => 'required|string|between:300,400', ])->fails(); return throw_unless($isValid, InvalidRecaptchaException::class, $request->only('_recaptcha')); From 0ae50e1d01beced56d69e287eceeacd0f61dae43 Mon Sep 17 00:00:00 2001 From: DarkGhostHunter Date: Thu, 13 Jun 2019 00:22:40 -0400 Subject: [PATCH 2/2] Fixed test for variable reCAPTCHA token. --- tests/Middleware/CheckRecaptchaTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Middleware/CheckRecaptchaTest.php b/tests/Middleware/CheckRecaptchaTest.php index f20037e..57575dc 100644 --- a/tests/Middleware/CheckRecaptchaTest.php +++ b/tests/Middleware/CheckRecaptchaTest.php @@ -86,7 +86,7 @@ public function testFailsOnNonPostMethod() public function testFailsInvalidToken() { - $response = $this->post('test-post', [ '_recaptcha' => Str::random(357)]); + $response = $this->post('test-post', [ '_recaptcha' => Str::random(401)]); $response->assertStatus(500); $this->assertInstanceOf(InvalidRecaptchaException::class, $response->exception);