【发布时间】:2018-01-29 22:34:57
【问题描述】:
如何覆盖 Laravel 的身份验证脚手架中重置密码的默认验证?
我已将以下方法从 ResetsPasswords 特征复制到我的 ResetPasswordController 中:
public function reset(Request $request)
{
$this->validate($request, $this->rules(), $this->validationErrorMessages());
// Here we will attempt to reset the user's password. If it is successful we
// will update the password on an actual user model and persist it to the
// database. Otherwise we will parse the error and return the response.
$response = $this->broker()->reset(
$this->credentials($request), function ($user, $password) {
$this->resetPassword($user, $password);
}
);
// If the password was successfully reset, we will redirect the user back to
// the application's home authenticated view. If there is an error we can
// redirect them back to where they came from with their error message.
return $response == Password::PASSWORD_RESET
? $this->sendResetResponse($response)
: $this->sendResetFailedResponse($request, $response);
}
/**
* Get the password reset validation rules.
*
* @return array
*/
protected function rules()
{
return [
'token' => 'required',
'email' => 'required|email',
'password' => 'required|confirmed|min:6',
];
}
如果我删除一条规则,例如使用长度小于 6 个字符的密码时仍会返回“min:6”错误消息。
我已经参考了相关文档,但我无法从中得到我需要的东西。
任何帮助将不胜感激,在此先感谢。
【问题讨论】:
标签: php laravel laravel-5.4