Do you have this: reset_password in your $fillable array of the User model? Because it obviously does not go to false. and make sure you use false with small, not False just in case it is case sensitive and depending on what type of data you can store in that column.
Dec 13, 2022
16
Level 14
This password reset token is invalid.
Hi, I am trying to implement a middleware which redirects the user to the reset password page. This should only occur if the user is created by the admin (the admin has to check a box so this middleware pops up).
I it redirecting correctly, and it's storing password reset token in the database but still gets This password reset token is invalid.
This is the middleware
class ChangedPassword
{
public function handle(Request $request, Closure $next)
{
if (Auth::user()->reset_password) {
$email = Auth::user()->email;
DB::table('password_resets')->insert([
'email' => $email,
'token' => Hash::make(Str::random(64)),
'created_at' => Carbon::now()
]);
$tokenData = DB::table('password_resets')->where('email', $email)->orderBy('created_at', 'desc')->first();
return redirect('/endurstilla-lykilorð/' . $tokenData->token);
}
return $next($request);
}
}
Added this to the NewPasswordController:
if ($status == Password::PASSWORD_RESET) {
\Auth::user()->update([
'reset_password' => False
]);
return redirect()->route('login')->with('status', __($status));
}
Any ideas?
Please or to participate in this conversation.