我在控制器中有这个函数,但是由于我想将字符长度改为5位数,所以无法重置密码。
public function postReset(Request $request)
{
$this->validate($request, [
'token' => 'required',
'password' => 'required|confirmed|digits:5',
]);
$credentials = $request->only(
'email', 'password', 'password_confirmation', 'token'
);
$response = Password::reset($credentials, function ($user, $password) {
$this->resetPassword($user, $password);
});
dd($response);
switch ($response) {
case Password::PASSWORD_RESET:
return redirect($this->redirectPath());
default:
return redirect()->back()
->withInput($request->only('email'))
->withErrors(['email' => trans($response)]);
}
}
protected function resetPassword($user, $password)
{
$user->password = bcrypt($password);
$user->save();
Auth::login($user);
}
但是它总是说:
哎呀!您的输入存在一些问题。
密码必须至少为六个字符,并与确认密码匹配。
当我添加了以下内容时:
dd($response);
输出:
passwords.password
有什么解决办法吗?
dd($request->all());
- AliRNazari