/** * Check email and password * Login user * @return bool */ public function login() { $username = $this->getAttribute('username'); $this->_user = $this->db->select(Db::TABLE_USER, array('username' => $username, 'password' => UserAuth::hash($this->getAttribute('password')))); if (!empty($this->_user)) { $identity = new UserAuth(); $identity->login($username); return true; } else { $this->addError('password', 'Incorrect username or password'); } return false; }
/** * Check if user authenticated? if not - does redirect */ public function checkAuthenticate() { $auth = new UserAuth(); if (!$auth->isAuthenticate()) { $this->redirect('/login'); } }