Fix validating captcha
This commit is contained in:
parent
b343707978
commit
b3876468b2
@ -140,8 +140,9 @@ class AuthController extends Controller
|
|||||||
|
|
||||||
public function handleForgot(Request $request, UserRepository $users)
|
public function handleForgot(Request $request, UserRepository $users)
|
||||||
{
|
{
|
||||||
if (! $this->checkCaptcha($request))
|
$this->validate($request, [
|
||||||
return json(trans('auth.validation.captcha'), 1);
|
'captcha' => 'required'.(app()->environment('testing') ? '' : '|captcha')
|
||||||
|
]);
|
||||||
|
|
||||||
if (config('mail.driver') == "")
|
if (config('mail.driver') == "")
|
||||||
return json(trans('auth.forgot.close'), 1);
|
return json(trans('auth.forgot.close'), 1);
|
||||||
|
@ -372,17 +372,9 @@ class AuthControllerTest extends TestCase
|
|||||||
{
|
{
|
||||||
Mail::fake();
|
Mail::fake();
|
||||||
|
|
||||||
// Should return a warning if `captcha` is wrong
|
|
||||||
$this->withSession(['phrase' => 'a'])->postJson('/auth/forgot', [
|
|
||||||
'captcha' => 'b'
|
|
||||||
])->assertJson([
|
|
||||||
'errno' => 1,
|
|
||||||
'msg' => trans('auth.validation.captcha')
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Should be forbidden if "forgot password" is closed
|
// Should be forbidden if "forgot password" is closed
|
||||||
config(['mail.driver' => '']);
|
config(['mail.driver' => '']);
|
||||||
$this->withSession(['phrase' => 'a'])->postJson('/auth/forgot', [
|
$this->postJson('/auth/forgot', [
|
||||||
'captcha' => 'a'
|
'captcha' => 'a'
|
||||||
])->assertJson([
|
])->assertJson([
|
||||||
'errno' => 1,
|
'errno' => 1,
|
||||||
|
Loading…
Reference in New Issue
Block a user