From eb62bd0b6fe886c7757112ca27ec8e741903e2c4 Mon Sep 17 00:00:00 2001 From: printempw Date: Sat, 7 Jul 2018 16:14:42 +0800 Subject: [PATCH] Use mail.driver to determine whether password reset is disabled --- app/Http/Controllers/AuthController.php | 6 +++--- tests/AuthControllerTest.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index a0ed0266..313bd3ae 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -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])); diff --git a/tests/AuthControllerTest.php b/tests/AuthControllerTest.php index 07982b14..57fa4cbb 100644 --- a/tests/AuthControllerTest.php +++ b/tests/AuthControllerTest.php @@ -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', [