简体   繁体   English

Laravel:针对用户的密码重置电子邮件检查

[英]Laravel : Password reset email check against user

I have the following code to send the password reset email to the users email which is working: 我有以下代码将密码重置电子邮件发送到正在工作的用户电子邮件:

$response = $this->passwords->sendResetLink($request->only('email'),function($message)
{
    $message->subject('Password Reminder');
});

What i want is that user should write their username instead of email, And i will check the email against that username , And will send the email.So i came up with this idea. 我想要的是用户应该username而不是电子邮件,然后我将对照该用户名检查电子邮件,并发送email.So,我想到了这个主意。

    $usernameToEmail = User::where('name','=', Input::get('username'))->first();  

    $response = $this->passwords->sendResetLink(['name' => $usernameToEmail],function($message)
    {
        $message->subject('Password Reminder');
    });

Which is not working also. 这也不起作用。

Am i missing something ? 我想念什么吗?

You're close, but your $usernameToEmail variable contains a User object, not an email string. 您接近了,但是您的$usernameToEmail变量包含一个User对象,而不是一个电子邮件字符串。 Most likely you just need to add a method to your chain: 您很可能只需要向链中添加一个方法:

$usernameToEmail = User::where('name','=', Input::get('username'))->first()->email;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM