-1

Why is that , when I'm resetting password the controller\auth\user is passing for request to reset not the User Model ? I didn't touch anything in the reset password controller, maybe I got an wrong import but I dont know how to solve this.

enter image description here

Here is the default ResetPasswordController code

public function create(Request $request): View
{
    return view('auth.reset-password', ['request' => $request]);
}

public function store(Request $request): RedirectResponse
{
    $request->validate([
        'token' => ['required'],
        'email' => ['required', 'string', 'email', 'max:255', 'unique:'.User::class],
        'password' => ['required', 'confirmed', Rules\Password::defaults()],
    ]);

  
    $status = Password::reset(
        $request->only('email', 'password', 'password_confirmation', 'token'),
        function ($user) use ($request) {
            $user->forceFill([
                'password' => Hash::make($request->password),
                'remember_token' => Str::random(60),
            ])->save();

            event(new PasswordReset($user));
        }
    );

    return $status == Password::PASSWORD_RESET
                ? redirect()->route('login')->with('status', __($status))
                : back()->withInput($request->only('email'))
                        ->withErrors(['email' => __($status)]);
    }
}

protected $table = 'users'; 

I tried this one but unlucky still error.

matiaslauriti
  • 7,065
  • 4
  • 31
  • 43

1 Answers1

0

Within your controller, try:

use App\Models\User;

$status = Password::reset(
     $request->only('email', 'password', 'password_confirmation', 'token'),
     function (User $user) use ($request) {
            $user->forceFill([
                'password' => Hash::make($request->password),
                'remember_token' => Str::random(60),
            ])->save();

            event(new PasswordReset($user));
      }
 );
Khang Tran
  • 2,015
  • 3
  • 7
  • 10