/** * Authentication * * @param frontDispatcher $front * @param string $authUrl the Auth URL * @param string $from, if set to 'ajax', it will return a json with error = false instead of * routing. * @return boolean */ public function authenticate(frontDispatcher $front, $authUrl, $from) { $actions = $this->getActions(); $controller = explode('Controller', $front->getController()); $controller = $controller[0]; $action = $front->getAction(); if (!isset($actions[$controller]) || isset($actions[$controller]) && isset($actions[$controller][$action]) && '1' === $actions[$controller][$action]) { // add this for preserved areas if (false === AuthManager::check()) { if ('ajax' == $from) { header('content-type: application/json'); $params = array('error' => 'true', 'url' => $authUrl); echo json_encode($params); } else { header("location: {$authUrl}"); } exit; } } }