setHost('') ->setScheme('') ->stripQuery('token'); $config = config(App::class); if ($config->forceGlobalSecureRequests) { // Remove "https:/" $current = substr($current, 7); } /** @var Router $router */ $router = service('router'); $routerParams = $router->params(); if ($routerParams === []) { return; } // no need to go through the unlock form if user is connected if (auth()->loggedIn()) { return; } // Make sure this isn't already a premium podcast route if ($current === route_to('premium-podcast-unlock', $routerParams[0])) { return; } // Make sure that public episodes are still accessible if ($routerParams >= 2 && ($episode = (new EpisodeModel())->getEpisodeBySlug( $routerParams[0], $routerParams[1] )) && ! $episode->is_premium) { return; } // Episode should be embeddable even if it is premium if ($current === route_to('embed', $episode->podcast->handle, $episode->slug)) { return; } // if podcast is locked then send to the unlock form /** @var PremiumPodcasts $premiumPodcasts */ $premiumPodcasts = service('premium_podcasts'); if (! $premiumPodcasts->check($routerParams[0])) { session()->set('redirect_url', current_url()); return redirect()->route('premium-podcast-unlock', [$routerParams[0]]); } } /** * @param array|null $arguments */ public function after(RequestInterface $request, ResponseInterface $response, $arguments = null): void { } }