route()?->getName() ?? '', 'two-factor.')) { return $next($request); } try { $response = $next($request); } catch (ValidationException $error) { // Exclude authentication material from old input without affecting other forms' code fields. $request->request->remove('code'); $request->request->remove('recovery_code'); $request->json()->remove('code'); $request->json()->remove('recovery_code'); throw $error; } if ($request->hasSession()) { $request->session()->forget(['_old_input.code', '_old_input.recovery_code']); } $response->headers->set('Cache-Control', 'private, no-store, max-age=0'); return $response; } }