我有这个代码:
$.ajax({
url: "/password/email",
data: {
_token: $(".modal-forgotpass-content input[name='_token']").val(),
email: $(".modal-forgotpass-content input[name='email']").val()
},
type: "POST",
success: function(data) {
alert("Successful : link send");
},
error: function(e) {
alert("Faild: link not send");
}
});
控制器(此功能随Laravel 5.4一起提供):
public function sendResetLinkEmail(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
// 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);
}
路线:
Auth::routes();
此代码运行良好,但即使数据库(用户表)中不存在该电子邮件,它也会将密码重置链接发送到所有电子邮件 . 我希望链接只发送到用户表中已存在的电子邮件 .
1 回答
而不是像使用验证
验证如下
这应验证用户电子邮件是否存在于数据库中 .