Example #1
0
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     $criteria = new EMongoCriteria();
     $criteria->username('==', $this->username);
     $userInfo = Admin::model()->find($criteria);
     if ($userInfo == NULL) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
         return false;
     }
     if ($userInfo->password !== md5($this->password)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
         return false;
     }
     $this->errorCode = self::ERROR_NONE;
     return true;
 }