Пример #1
0
 function validate($username, $password)
 {
     $session = Node::getOne(array(Node::FIELD_COLLECTION => FRAMEWORK_COLLECTION_SESSION, 'username' => Database::escapeValue($username)));
     $res = Session::validate($username, $password, $this->request()->fingerprint());
     if (is_int($res)) {
         switch ($res) {
             case Session::ERR_MISMATCH:
                 throw new ServiceException('Username and password mismatch.', $res);
                 break;
             case Session::ERR_EXISTS:
                 throw new ServiceException('Session already exists.', $res);
                 break;
         }
     }
     return $res;
 }
Пример #2
0
 /**
  * Loads data into current intance with specified $entityId from collection.
  *
  * @param {array|string|number} $filter Scalar types will be treated as identity,
  *                                      array types will be used as is.
  */
 function load($identity)
 {
     if (!$identity) {
         return $this;
     }
     $identity = Database::escapeValue($identity);
     $filter = array(Node::FIELD_COLLECTION => self::collectionName());
     if (is_scalar($identity)) {
         $filter[$this->_primaryKey] = $identity;
     } else {
         if (is_array($identity)) {
             $filter += $identity;
         }
     }
     $this->beforeLoad($filter);
     if ($filter !== false) {
         $this->data((array) @Node::getOne($filter));
         $this->afterLoad();
     }
     return $this;
 }