Use mail.driver to determine whether password reset is disabled

This commit is contained in:
printempw 2018-07-07 16:14:42 +08:00
parent 2a35e83939
commit eb62bd0b6f
2 changed files with 6 additions and 6 deletions

View File

@ -156,7 +156,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);
@ -168,7 +168,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)
@ -188,7 +188,7 @@ class AuthController extends Controller
try {
Mail::send('auth.mail', ['reset_url' => $url], function ($m) use ($request) {
$site_name = Option::get('site_name');
$site_name = option_localized('site_name');
$m->from(config('mail.username'), $site_name);
$m->to($request->input('email'))->subject(trans('auth.mail.title', ['sitename' => $site_name]));

View File

@ -395,7 +395,7 @@ class AuthControllerTest extends TestCase
{
$this->visit('/auth/forgot')->see('Forgot Password');
config(['mail.host' => '']);
config(['mail.driver' => '']);
$this->visit('/auth/forgot')->see(trans('auth.forgot.close'));
}
@ -410,14 +410,14 @@ class AuthControllerTest extends TestCase
]);
// Should be forbidden if "forgot password" is closed
config(['mail.host' => '']);
config(['mail.driver' => '']);
$this->withSession(['phrase' => 'a'])->post('/auth/forgot', [
'captcha' => 'a'
])->seeJson([
'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()])->post('/auth/forgot', [