无需覆盖
sendResetLinkEmail
函数,您只需覆盖
validateEmail
这样地
protected function validateEmail(Request $request)
{
$this->validate($request,
['email' => ['required','email',
Rule::exists('users')->where(function ($query) {
$query->where('active', 1);
})
]
]
);
}
或
如果要重定向到自定义URL,请覆盖
发送resetlinkemail
像这样的手动验证功能
public function sendResetLinkEmail(Request $request)
{
$validator = Validator::make($request->all(), [
'email' => ['required', 'email',
Rule::exists('users')->where(function ($query) {
$query->where('active', 1);
})
]
]);
if ($validator->fails()) {
return redirect('some_other_url')
->with('fail', 'You can not request reset password, account is block');
}
// 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);
}