/**
* {@inheritdoc}
*
* @param string $module
* @param string $controller
* @param array $params
* @return void
*/
protected function preDispatch($module, $controller, $params = array())
{
// example of setup default title
Layout::title("Bluz Skeleton");
// apply "remember me" function
if (!AuthProxy::getIdentity()) {
if ($token = Request::getHeader('Bluz-Token')) {
Auth\Table::getInstance()->authenticateToken($token);
} elseif (!empty($_COOKIE['rToken']) && !empty($_COOKIE['rId'])) {
// try to login
try {
Auth\Table::getInstance()->authenticateCookie($_COOKIE['rId'], $_COOKIE['rToken']);
} catch (AuthException $e) {
$this->getResponse()->setCookie('rId', '', 1, '/');
$this->getResponse()->setCookie('rToken', '', 1, '/');
}
}
}
parent::preDispatch($module, $controller, $params);
}