Save URL to redirect to after authentication to session.

@param \Cake\Http\ServerRequest $request Request instance.

@return void
547494
protected function _setRedirectUrl(ServerRequest $request)
    {
        $request->getSession()->delete('SocialAuth.redirectUrl');

        $redirectUrl = $request->getQuery(static::QUERY_STRING_REDIRECT);
        if (empty($redirectUrl)
            || substr($redirectUrl, 0, 1) !== '/'
            || substr($redirectUrl, 0, 2) === '//'
        ) {
            return;
        }

        $request->getSession()->write('SocialAuth.redirectUrl', $redirectUrl);
    }
604417
public function run(ServerRequestInterface $request): void
    {
        $this->emitter->emit(
            $this->middleware->handle($request)
        );
    }
1210818
protected function authorize(Request $request)
    {
        $authorizer = $this->resolveAuthorizer($request);

        if ($authorizer) {
            $authorizer->authorize($this->getSubject());
        }
    }
1144473
public function onLogoutSuccess(Request $request)
    {
        phpCAS::setDebug($this->cas->getDebug());
        phpCAS::setVerbose($this->cas->isVerbose());
        if (!phpCAS::isInitialized()) {
            phpCAS::client(
                $this->cas->getVersion(),
                $this->cas->getHostname(),
                $this->cas->getPort(),
                $this->cas->getUrl()
            );
        }
        phpCAS::setLang($this->cas->getLanguage());

        if ($this->cas->isRedirectingAfterLogout()) {
            $uri = $this->router->generate(
                $this->cas->getRouteLogout(),
                [],
                UrlGeneratorInterface::ABSOLUTE_URL
            );
            phpCAS::logoutWithRedirectService($uri);
        } else {
            //simple logout
            phpCAS::logout();
        }
    }
55461
public function dispatch(ServerRequest $request = null)
    {
        $response = $this->respond($request ? : $this->request);

        $response->send();
    }
302919
private function canHandleRedirect(Request $request)
    {
        $session = $request->getSession();
        return (is_a($session, '\Symfony\Component\HttpFoundation\Session\SessionInterface') ||  is_a($session, '\Illuminate\Contracts\Session\Session')) &&
            $request->headers->has(self::ORIGIN_REQUEST_HEADER);
    }
1322304
public function bindRequest(Request $request)
    {
        $this->request = $request;

        foreach ($this->request->postArray() as $key => $value) {
            if (isset($this->fieldSet[$key])) {
                $this->fieldSet[$key]->setValue($value);
            }
        }
    }
603401
private function cors($request)
  {
    $origin  = $request->server->http_origin;
    $allowed = Config::get('cors.allowedOrigins');

    if (in_array('*', $allowed) || in_array($origin, $allowed) ) {
      $this->withHeaders($request);
    }
  }
873935
public function init($request)
    {
        $this->app->instance('request', $request);
        Facade::clearResolvedInstance('request');
        $this->bootstrap();
    }
1071971
public function execute($request): void
    {
        RequestNotSupportedException::assertSupports($this, $request);

        $request->setResult([
            Constants::FIELD_PAID => false,
        ]);
    }
427766
private function saveReferrer(ServerRequestInterface $request)
    {
        Respond::session()->set(self::REFERRER, $request->getUri()->__toString());
    }
1284036
public function handleHttpRequest($request)
    {
        $this->parseRequestBase($request);

        if (isset($request->header['x-rpc']) && $request->header['x-rpc'] == 1) {
            $this->routeParams->isRpc          = true;
            $this->routeParams->params         = $request->post ?? $request->get ?? [];
            $this->routeParams->controllerName = 'Rpc';
            $this->routeParams->methodName     = 'Index';
            $this->controllerClassName         = '\PG\MSF\Controllers\Rpc';
            $this->routeParams->path           = '/Rpc/Index';
        } else {
            if ($this->routeParams->path) {
                $this->parsePath($this->routeParams->path);
            }
        }
    }
787935
protected function storePasswordHashInSession($request)
    {
        if (! $request->user()) {
            return;
        }

        $request->session()->put([
            'password_hash' => $request->user()->getAuthPassword(),
        ]);
    }
932737
protected function initSession(Request $request)
    {
        $this->checkParams($request->request);

        $this->initSessionBag(true);
        foreach($request->request->all() as $key => $value) {
            $this->sessionBag->set($key, $value);
        }
        if ($request->request->has('returnUrl')) {
            $this->sessionBag->set("referrer", $request->request->get('returnUrl'));
        } else {
            $this->sessionBag->set("referrer", $request->server->get("HTTP_REFERER"));
        }
    }
461027
protected function appendNextUrl(Request $request)
    {
        return !empty($request->getPathInfo()) && strpos($request->getPathInfo(), $this->loginPath) == false;
    }
1354828
public function store(CreateRedirectRequest $request)
    {
        $this->authorize(RedirectsPolicy::PERMISSION_CREATE);

        $redirect = Redirect::createRedirect(
            $request->getValidatedData()
        );

        $this->transNotification('created', [], $redirect->toArray());

        return redirect()->route('admin::seo.redirects.show', [$redirect]);
    }
453265
public function loginHeaders(ServerRequest $request)
    {
        $realm = $this->getConfig('realm') ?: $request->getEnv('SERVER_NAME');

        return [
            'WWW-Authenticate' => sprintf('Basic realm="%s"', $realm)
        ];
    }