Fix validating captcha
This commit is contained in:
parent
201fe21e6d
commit
8bd60624a0
|
|
@ -40,8 +40,7 @@ class AuthController extends Controller
|
||||||
$user = $users->get($identification, $authType);
|
$user = $users->get($identification, $authType);
|
||||||
|
|
||||||
if (session('login_fails', 0) > 3) {
|
if (session('login_fails', 0) > 3) {
|
||||||
if (strtolower($request->input('captcha')) != strtolower(session('phrase')))
|
$this->validate($request, ['captcha' => 'required|captcha']);
|
||||||
return json(trans('auth.validation.captcha'), 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $user) {
|
if (! $user) {
|
||||||
|
|
|
||||||
|
|
@ -93,19 +93,15 @@ class AuthControllerTest extends TestCase
|
||||||
$this->flushSession();
|
$this->flushSession();
|
||||||
|
|
||||||
// Should check captcha if there are too many fails
|
// Should check captcha if there are too many fails
|
||||||
$this->withSession(
|
$this->withSession(['login_fails' => 4])
|
||||||
[
|
->postJson(
|
||||||
'login_fails' => 4
|
'/auth/login', [
|
||||||
]
|
'identification' => $user->email,
|
||||||
)->postJson(
|
'password' => '12345678',
|
||||||
'/auth/login', [
|
])->assertJson([
|
||||||
'identification' => $user->email,
|
'errno' => 1,
|
||||||
'password' => '12345678',
|
'msg' => trans('validation.required', ['attribute' => 'captcha'])
|
||||||
'captcha' => 'b'
|
]);
|
||||||
])->assertJson([
|
|
||||||
'errno' => 1,
|
|
||||||
'msg' => trans('auth.validation.captcha')
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->flushSession();
|
$this->flushSession();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user