original_string: 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);
      }
code: 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);
      }
code_tokens: 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 ) ; }
docstring: Handle unauthorized access attempt
  
  @param \Cake\Controller\Controller $controller A reference to the controller object
  @return \Cake\Http\Response
  @throws \Cake\Http\Exception\ForbiddenException
docstring_tokens: Handle unauthorized access attempt