public function loginRequired($checkAjax = true, $checkAcceptHeader = true)
    {
        $request = $this->request;
        $canRedirect = !$checkAcceptHeader || $this->checkRedirectAcceptable();
        if ($this->enableSession
            && $request->getIsGet()
            && (!$checkAjax || !$request->getIsAjax())
            && $canRedirect
        ) {
            $this->setReturnUrl($request->getUrl());
        }
        if ($this->loginUrl !== null && $canRedirect) {
            $loginUrl = (array)$this->loginUrl;
            if ($loginUrl[0] !== $this->app->getRoute()->getRoutePath(true)) {
                return $this->app->response->redirect($this->loginUrl);
            }
        }
        throw new ForbiddenException(Reaction::t('rct', 'Login Required'));
    }
public function loginRequired($checkAjax = true, $checkAcceptHeader = true)
    {
        $request = $this->request;
        $canRedirect = !$checkAcceptHeader || $this->checkRedirectAcceptable();
        if ($this->enableSession
            && $request->getIsGet()
            && (!$checkAjax || !$request->getIsAjax())
            && $canRedirect
        ) {
            $this->setReturnUrl($request->getUrl());
        }
        if ($this->loginUrl !== null && $canRedirect) {
            $loginUrl = (array)$this->loginUrl;
            if ($loginUrl[0] !== $this->app->getRoute()->getRoutePath(true)) {
                return $this->app->response->redirect($this->loginUrl);
            }
        }
        throw new ForbiddenException(Reaction::t('rct', 'Login Required'));
    }
public function loginRequired ( $ checkAjax = true , $ checkAcceptHeader = true ) { $ request = $ this -> request ; $ canRedirect = ! $ checkAcceptHeader || $ this -> checkRedirectAcceptable ( ) ; if ( $ this -> enableSession && $ request -> getIsGet ( ) && ( ! $ checkAjax || ! $ request -> getIsAjax ( ) ) && $ canRedirect ) { $ this -> setReturnUrl ( $ request -> getUrl ( ) ) ; } if ( $ this -> loginUrl !== null && $ canRedirect ) { $ loginUrl = ( array ) $ this -> loginUrl ; if ( $ loginUrl [ 0 ] !== $ this -> app -> getRoute ( ) -> getRoutePath ( true ) ) { return $ this -> app -> response -> redirect ( $ this -> loginUrl ) ; } } throw new ForbiddenException ( Reaction :: t ( 'rct' , 'Login Required' ) ) ; }
Redirects the user browser to the login page.

Before the redirection, the current URL (if it's not an AJAX url) will be kept as [[returnUrl]] so that
the user browser may be redirected back to the current page after successful login.

Make sure you set [[loginUrl]] so that the user browser can be redirected to the specified login URL after
calling this method.

Note that when [[loginUrl]] is set, calling this method will NOT terminate the application execution.

@param bool $checkAjax whether to check if the request is an AJAX request. When this is true and the request
is an AJAX request, the current URL (for AJAX request) will NOT be set as the return URL.
@param bool $checkAcceptHeader whether to check if the request accepts HTML responses. Defaults to `true`. When this is true and
the request does not accept HTML responses the current URL will not be SET as the return URL. Also instead of
redirecting the user an ForbiddenHttpException is thrown. This parameter is available since version 2.0.8.
@return ResponseBuilderInterface the redirection response if [[loginUrl]] is set
@throws ForbiddenException the "Access Denied" HTTP exception if [[loginUrl]] is not set or a redirect is
not applicable.
Redirects the user browser to the login page .