use mail.driver to determine whether password reset is disabled

This commit is contained in:
Pig Fang 2018-07-15 18:18:56 +08:00
parent 5a0908517e
commit 590f62d035
2 changed files with 5 additions and 5 deletions

View File

@ -157,7 +157,7 @@ class AuthController extends Controller
public function forgot()
{
if (config('mail.host') != "") {
if (config('mail.driver') != "") {
return view('auth.forgot');
} else {
throw new PrettyPageException(trans('auth.forgot.close'), 8);
@ -169,7 +169,7 @@ class AuthController extends Controller
if (! $this->checkCaptcha($request))
return json(trans('auth.validation.captcha'), 1);
if (config('mail.host') == "")
if (config('mail.driver') == "")
return json(trans('auth.forgot.close'), 1);
if (Session::has('last_mail_time') && (time() - session('last_mail_time')) < 60)

View File

@ -396,7 +396,7 @@ class AuthControllerTest extends TestCase
{
$this->get('/auth/forgot')->assertSee('Forgot Password');
config(['mail.host' => '']);
config(['mail.driver' => '']);
$this->get('/auth/forgot')->assertSee(trans('auth.forgot.close'));
}
@ -413,14 +413,14 @@ class AuthControllerTest extends TestCase
]);
// Should be forbidden if "forgot password" is closed
config(['mail.host' => '']);
config(['mail.driver' => '']);
$this->withSession(['phrase' => 'a'])->postJson('/auth/forgot', [
'captcha' => 'a'
])->assertJson([
'errno' => 1,
'msg' => trans('auth.forgot.close')
]);
config(['mail.host' => 'localhost']);
config(['mail.driver' => 'smtp']);
// Should be forbidden if sending email frequently
$this->withSession(['last_mail_time' => time()])->postJson('/auth/forgot', [