Cake\Controller\Component\AuthComponent::_unauthorized PHP Method

_unauthorized() protected method

Handle unauthorized access attempt
protected _unauthorized ( Controller $controller ) : Response
$controller Cake\Controller\Controller A reference to the controller object
return Cake\Network\Response
    protected function _unauthorized(Controller $controller)
    {
        if ($this->_config['unauthorizedRedirect'] === false) {
            throw new ForbiddenException($this->_config['authError']);
        }
        $this->flash($this->_config['authError']);
        if ($this->_config['unauthorizedRedirect'] === true) {
            $default = '/';
            if (!empty($this->_config['loginRedirect'])) {
                $default = $this->_config['loginRedirect'];
            }
            if (is_array($default)) {
                $default['_base'] = false;
            }
            $url = $controller->referer($default, true);
        } else {
            $url = $this->_config['unauthorizedRedirect'];
        }
        return $controller->redirect($url);
    }