Reset password token expiry laravel custom api

1.9k views Asked by At

i have created a custom send password reset link api in my laravel application and that is working absolutely fine but i want to expire my link after some time like as default laravel password reset token expire after some time but in my case it does not expire at all here is my api

 public function forgotPassword(Request $request)
{
    $request->validate([
        'email' => 'required|email|exists:users',
    ]);

    $token = Str::random(64);
    $code = mt_rand(100000,999999);

    DB::table('password_resets')->insert([
        'email' => $request->email,
        'token' => $token,
        'code' => $code,
        'created_at' => Carbon::now()
    ]);


    Mail::to(request('email'))->send(new ForgotPassword([
        'token' => $token,
        'code' => $code,]));
    
    return response()->json(['status' => true, 'message' => 'Reset password link has been sent to your email id.!']);
}

please guide me what should i do. I'll appreciate your response thank you in advance

0

There are 0 answers