Update mail template of password reset

This commit is contained in:
Pig Fang 2018-08-16 18:10:09 +08:00
parent daaedeed7e
commit 706ca1938b
7 changed files with 23 additions and 42 deletions

View File

@ -167,12 +167,12 @@ class AuthController extends Controller
} catch (\Exception $e) {
report($e);
return json(trans('auth.mail.failed', ['msg' => $e->getMessage()]), 2);
return json(trans('auth.forgot.failed', ['msg' => $e->getMessage()]), 2);
}
Session::put('last_mail_time', time());
return json(trans('auth.mail.success'), 0);
return json(trans('auth.forgot.success'), 0);
}
public function reset($uid, UserRepository $users)

View File

@ -14,7 +14,7 @@ class ForgotPassword extends Mailable
/**
* @var string
*/
public $reset_url = '';
public $url = '';
/**
* Create a new message instance.
@ -24,7 +24,7 @@ class ForgotPassword extends Mailable
*/
public function __construct(string $url)
{
$this->reset_url = $url;
$this->url = $url;
}
/**
@ -37,7 +37,7 @@ class ForgotPassword extends Mailable
$site_name = option_localized('site_name');
return $this->from(config('mail.username'), $site_name)
->subject(trans('auth.mail.title', ['sitename' => $site_name]))
->view('auth.mail');
->subject(trans('auth.forgot.mail.title', ['sitename' => $site_name]))
->view('mails.password-reset');
}
}

View File

@ -29,15 +29,17 @@ forgot:
close: Password resetting is not available now.
frequent-mail: You click the send button too fast. Wait for 60 secs, guy.
unregistered: The email address is not registered.
mail:
title: Reset your password on :sitename
success: Mail is sent. Will be expired in 1 hour, please check.
failed: Fail to send mail, detailed message :msg
message: You are receiving this email because this email address was used to reset your password on :sitename
ignore: If you haven't signed up on our site, please ignore this email. No unsubscribing is required.
reset: Reset your password
notice: This mail is sending automatically, no reponses will be sent if you reply.
mail:
title: Reset your password on :sitename
message: You are receiving this email because we received a password reset request for your account on :sitename.
reset: "To reset your password, please visit: :url"
ignore: If you did not request a password reset, no further action is required.
reset:
title: Reset Password

View File

@ -29,15 +29,17 @@ forgot:
close: 本站已关闭重置密码功能
frequent-mail: 你邮件发送得太频繁啦,过 60 秒后再点发送吧
unregistered: 该邮箱尚未注册
mail:
title: 重置您在 :sitename 上的账户密码
success: 邮件已发送,一小时内有效,请注意查收。
failed: 邮件发送失败,详细信息::msg
message: 您收到这封邮件,是因为在 :sitename 的用户重置密码功能使用了您的地址。
ignore: 如果您并没有访问过我们的网站,或没有进行上述操作,请忽略这封邮件。 您不需要退订或进行其他进一步的操作。
reset: 重置密码
notice: 本邮件由系统自动发送,就算你回复了我们也不会回复你哦
mail:
title: 重置您在 :sitename 上的账户密码
message: 您收到这封邮件,是因为有人在 :sitename 的密码重置功能中使用了您的地址。
reset: 点击此链接重置您的密码::url
ignore: 如果您并没有访问过我们的网站,或没有进行上述操作,请忽略这封邮件。
reset:
title: 重置密码

View File

@ -1,26 +0,0 @@
<div style="background:#444;padding:0">
<link rel="stylesheet" type="text/css" href="https://work.prinzeugen.net/font/Minecraft.css">
<div style="min-height:100%;background:#444;padding:80px 0;margin:0;font-size:14px;line-height:1.7;font-family:'Helvetica Neue',Arial,'Microsoft Yahei','Microsoft Jhenghei',sans-serif;color:#444">
<center>
<div style="margin:0 auto;width:580px;background:#fff;text-align:left">
<h1 style="margin:0 40px;color:#999;border-bottom:1px dotted #ddd;padding:40px 0 30px;text-align:center;font-size: 35px;font-family:Minecraft,Copperplate,'Copperplate Gothic Light',Palatino,'Palatino Linotype','Palatino LT STD',Georgia,'Microsoft Yahei','Microsoft Jhenghei',serif">
{{ option_localized('site_name') }}
</h1>
<div style="padding:30px 40px 40px">{!! trans('auth.mail.message', ['sitename' => "<a style='color:#009a61;text-decoration:none' href='".option('site_url')."'>".option_localized('site_name')."</a>"]) !!}<br><br>
<div style="border-left:5px solid #ddd;padding:0 0 0 24px;color:#888">
@lang('auth.mail.ignore')
</div>
</div>
<div style="background:#eee;border-top:1px solid #ddd;text-align:center;min-height:90px;line-height:90px">
<a href="{{ $reset_url }}" style="padding:8px 18px;background:#009a61;color:#fff;text-decoration:none;border-radius:3px" target="_blank">
@lang('auth.mail.reset')
</a>
</div>
</div>
<div style="padding-top:30px;text-align:center;font-size:12px;color:#999">
* @lang('auth.mail.notice') <br>
</div>
</center>
</div>
<div style="min-height:100%;background:#444;padding:40px 0;margin:0;font-size:14px;line-height:1.7;font-family:'Helvetica Neue',Arial,'Microsoft Yahei','Microsoft Jhenghei',sans-serif;color:#444"></div>
</div>

View File

@ -0,0 +1,3 @@
<p>{!! trans('auth.forgot.mail.message', ['sitename' => option_localized('site_name')]) !!}</p>
<p>{!! trans('auth.forgot.mail.reset', ['url' => $url]) !!}</p>
<p>{!! trans('auth.forgot.mail.ignore') !!}</p>

View File

@ -412,7 +412,7 @@ class AuthControllerTest extends TestCase
'captcha' => 'a'
])->assertJson([
'errno' => 0,
'msg' => trans('auth.mail.success')
'msg' => trans('auth.forgot.success')
])->assertSessionHas('last_mail_time');
Mail::assertSent(ForgotPassword::class, function ($mail) use ($user) {
return $mail->hasTo($user->email);
@ -429,7 +429,7 @@ class AuthControllerTest extends TestCase
'captcha' => 'a'
])->assertJson([
'errno' => 2,
'msg' => trans('auth.mail.failed', ['msg' => 'A fake exception.'])
'msg' => trans('auth.forgot.failed', ['msg' => 'A fake exception.'])
]);
// Addition: Mailable test
@ -437,8 +437,8 @@ class AuthControllerTest extends TestCase
$mailable = new ForgotPassword('url');
$mailable->build();
$this->assertTrue($mailable->hasFrom(config('mail.username'), $site_name));
$this->assertEquals(trans('auth.mail.title', ['sitename' => $site_name]), $mailable->subject);
$this->assertEquals('auth.mail', $mailable->view);
$this->assertEquals(trans('auth.forgot.mail.title', ['sitename' => $site_name]), $mailable->subject);
$this->assertEquals('mails.password-reset', $mailable->view);
}
public function testReset()