middleware('guest'); } /** * Display the password reset view for the given token. * * If no token is present, display the link request form. * * @return Factory|View */ public function showResetForm(Request $request) { $token = $request->route()->parameter('token'); return view('auth.passwords.reset')->with( ['token' => $token, 'username' => $request->username] ); } /** * Get the password reset validation rules. * * @return array */ protected function rules() { return [ 'token' => 'required', 'username' => 'required|regex:/^[a-zA-Z0-9]*$/|max:20', 'password' => [ 'required', 'confirmed', Password::defaults(), ], ]; } /** * Get the password reset credentials from the request. * * @return array */ protected function credentials(Request $request) { // Find the user_id and use that for the credentials $userId = Username::firstWhere('username', $request->username)?->user_id; $request->merge(['id' => $userId]); return $request->only( 'id', 'password', 'password_confirmation', 'token' ); } /** * Get the response for a failed password reset. * * @param string $response * @return RedirectResponse|JsonResponse */ protected function sendResetFailedResponse(Request $request, $response) { return back() ->withInput($request->only('username')) ->withErrors(['username' => trans($response)]); } }