I have this function in controller and I can't reset password
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);
}
but it always says
Whoops! There were some problems with your input.
Passwords must be at least six characters and match the confirmation.
and when I added
dd($response);
it prints passwords.password
Any idea how to solve this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire