【问题标题】:Laravel 5 send password reset and custom input nameLaravel 5 发送密码重置和自定义输入名称
【发布时间】:2018-11-13 18:10:58
【问题描述】:

我想在同一页面上注册/登录和发送密码重置。

我实现了使用不同的输入名称在同一页面上注册和登录。但是我没有找到添加密码重置输入的方法。

我想将其称为“reset_email”,但在我的控制器上,如果我尝试:

public function sendResetLinkEmail(Request $request)
{
    $this->validateEmail($request);

    // We will send the password reset link to this user. Once we have attempted
    // to send the link, we will examine the response then see the message we
    // need to show to the user. Finally, we'll send out a proper response.
    $response = $this->broker()->sendResetLink(
        $request->only('email')
    );

    return $response == Password::RESET_LINK_SENT
                ? $this->sendResetLinkResponse($response)
                : $this->sendResetLinkFailedResponse($request, $response);
}

/**
 * Validate the email for the given request.
 *
 * @param \Illuminate\Http\Request  $request
 * @return void
 */
protected function validateEmail(Request $request)
{
    $this->validate($request, ['reset_email' => 'required|email']);
}

我遇到了这个错误:

我们找不到使用该电子邮件地址的用户。

知道如何使用 reset_email 而不是 email 作为我的输入名称吗?

感谢您的帮助。

【问题讨论】:

    标签: php laravel


    【解决方案1】:

    像这样更新你的方法:

    ...
    $response = $this->broker()->sendResetLink(
        ['email' => $request->get('reset_email')]
    );
    ...
    

    这将获取您的输入值并将其发送到密码代理,密钥为 email,因此它将按此列查找用户。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-02
      • 2016-03-01
      • 2015-07-18
      • 2017-07-07
      • 2015-05-27
      • 2014-11-22
      • 1970-01-01
      • 2023-03-27
      相关资源
      最近更新 更多