/** * @inheritDoc */ protected function _beforeInsert() { $this->_fields['salt'] = uniqid(); $this->_fields['password'] = Token::cryptPassword($this->_fields['password'], $this->_fields['salt']); $this->_fields['name'] = 'User'; $date = $this->_getCurrentDate(); $this->_fields['created_at'] = $date->format('Y-m-d'); $this->_fields['last_activity'] = $date->format('Y-m-d H:i:s'); }
/** * Injects particular page content into the main layout and sends it as response * * @param string $content */ private static function _sendResponse($content) { $renderer = new Renderer(APP_PATH . '/layout.html.php'); $renderer->assign(array('content' => $content, 'user' => Token::getUser(), 'route' => Router::getInstance()->getRoute())); $response = $renderer->render(); Connection::getInstance()->disconnect(); echo $response; Token::set('flush', null); exit; }
/** * Checks is user already authenicated and redirects to dashboard if it is */ private function _redirectIfLoggedIn() { if (Token::getUser()) { $this->redirect('/'); } }
<li><a href="/logout">Logout</a></li> </ul> </li> <?php } ?> </ul> </div> </div> </div> <div class="container theme-showcase" role="main"> <div class="row"> <?php if ($message = \Kernel\Security\Token::get('flush')) { ?> <div class="alert alert-info alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <?php echo $message; ?> </div> <?php } ?> <?php echo $content; ?>
/** * @inheritDoc */ public function getUser() { return Token::getUser(); }