diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 24d6f99a..5e3fd56f 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -40,8 +40,7 @@ class AuthController extends Controller $user = $users->get($identification, $authType); if (session('login_fails', 0) > 3) { - if (strtolower($request->input('captcha')) != strtolower(session('phrase'))) - return json(trans('auth.validation.captcha'), 1); + $this->validate($request, ['captcha' => 'required|captcha']); } if (! $user) { diff --git a/tests/AuthControllerTest.php b/tests/AuthControllerTest.php index c09c5aec..8cba7e30 100644 --- a/tests/AuthControllerTest.php +++ b/tests/AuthControllerTest.php @@ -93,19 +93,15 @@ class AuthControllerTest extends TestCase $this->flushSession(); // Should check captcha if there are too many fails - $this->withSession( - [ - 'login_fails' => 4 - ] - )->postJson( - '/auth/login', [ - 'identification' => $user->email, - 'password' => '12345678', - 'captcha' => 'b' - ])->assertJson([ - 'errno' => 1, - 'msg' => trans('auth.validation.captcha') - ]); + $this->withSession(['login_fails' => 4]) + ->postJson( + '/auth/login', [ + 'identification' => $user->email, + 'password' => '12345678', + ])->assertJson([ + 'errno' => 1, + 'msg' => trans('validation.required', ['attribute' => 'captcha']) + ]); $this->flushSession();