user(); if (!$user) { return $next($request); } // Check if the current route is excluded foreach ($this->excludedRoutes as $excludedRoute) { if ($request->routeIs($excludedRoute)) { return $next($request); } } // Check if user needs to accept or re-accept principles if ($user->needsToReacceptPrinciples()) { // Redirect to principles page with appropriate message $principlesUrl = LaravelLocalization::localizeUrl(route('static-principles')); $message = $user->hasAcceptedPrinciples() ? __('Our principles have been updated. Please review and accept the new version to continue.') : __('Please accept the platform principles to continue.'); // Continue to the requested page after accepting (e.g. a poll opened from a mailing) if ($request->isMethod('GET') && !$request->ajax() && !$request->hasHeader('X-Livewire')) { session(['principles_intended_url' => $request->fullUrl()]); } return redirect()->to($principlesUrl) ->with('warning', $message); } return $next($request); } }