validate([ 'email' => 'required|email', ]); try { $action->execute($data); return to_route('password.reset.show.verify')->with('success', 'Password reset code is sent'); } catch (UserNotFoundException $e) { return to_route('password.reset.show.verify')->with('success', 'Password reset code is sent'); } } public function showVerify() { return view('auth.passwords.verify'); } public function verify(Request $request, OTPService $otpService) { $data = $request->validate(['otp' => 'required|string:min:5:max:6']); try { $isVerified = $otpService->verify($data['otp']); if (! $isVerified) { return back()->with('error', 'Invalid OTP'); } return to_route('password.reset.show.update')->with('success', 'OTP Verified'); } catch (UserNotFoundException $e) { return back()->with('error', 'Session Expired'); } } public function showUpdate() { return view('auth.passwords.update'); } public function update(Request $request) { $data = $request->validate(['password' => 'required', 'confirmed', Password::min(8)->letters()->mixedCase()->numbers()->symbols()]); $user = User::find(Session::get('user_id')); if (! $user) { return back()->with('error', 'Session Expired'); } $user->update(['password' => $data['password']]); return to_route('login.create')->with('success', 'Password updated successfully'); } }