Example #1
0
 /** 
  * Valid User function
  * verifies that user is an authorized user on the system. If they
  * are, then will login the user to the system
  * @param type $username the user's username
  * @param type $password the user's password
  * @return boolean returns true if user is authorized
  */
 public function valid_user($username, $password)
 {
     /* validate entry format and filter */
     $username = Validate::validate_string($username);
     $password = Validate::validate_string($password);
     /* clear username to present on views */
     Session::set('username', '');
     Session::set('uid', NULL);
     $sql = "SELECT id, \n            password, activation FROM users \n          WHERE \n            username = ? ";
     $this->_setSql($sql);
     $array = $this->fetch_record(array($username));
     Session::clear_error_output();
     if ($this->logged_in($password, $array)) {
         Session::set_user_data($username, $array['id']);
         return TRUE;
     } else {
         Session::set_error_output('Invalid login. Please re-enter your password');
         return FALSE;
     }
 }