public function authCheck(Event $event)
{
if ($this->_config['checkAuthIn'] !== $event->name()) {
return null;
}
/* @var \Cake\Controller\Controller $controller */
$controller = $event->subject();
$action = strtolower($controller->request->params['action']);
if (!$controller->isAction($action)) {
return null;
}
$this->_setDefaults();
if ($this->_isAllowed($controller)) {
return null;
}
$isLoginAction = $this->_isLoginAction($controller);
if (!$this->_getUser()) {
if ($isLoginAction) {
return null;
}
$result = $this->_unauthenticated($controller);
if ($result instanceof Response) {
$event->stopPropagation();
}
return $result;
}
if ($isLoginAction || empty($this->_config['authorize']) || $this->isAuthorized($this->user())) {
return null;
}
$event->stopPropagation();
return $this->_unauthorized($controller);
}