/** * Renders login form and authenticates user after form submitting * * @return string */ public function loginAction() { $this->_redirectIfLoggedIn(); $errors = array(); if (Request::isPost()) { $model = new SecurityModel(); if ($item = $model->set('email', Request::get('email'))->getItem()) { if (0 === strcmp(Token::cryptPassword(Request::get('password'), $item->salt), $item->password)) { Token::setUser($item); $this->redirect('/'); } } array_push($errors, 'Invalid username or password'); } return $this->_renderView('login.html', array('errors' => $errors)); }