示例#1
0
 /**
  * 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;
 }
示例#2
0
 /**
  * Check if user authenticated? if not - does redirect
  */
 public function checkAuthenticate()
 {
     $auth = new UserAuth();
     if (!$auth->isAuthenticate()) {
         $this->redirect('/login');
     }
 }