mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-21 06:19:38 +08:00
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);
|
||||
|
||||
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) {
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user