Example #1
0
 /**
  * Validates the user and throws a validation error if there are any errors.
  * @throws ValidationException if there are any validation errors
  */
 public function ValidateUser()
 {
     if ($this->GetOAuth2Info() === null) {
         throw new ValidationException('OAuth2Info', null, 'OAuth 2.0 configuration is required.');
     }
     parent::ValidateOAuth2Info();
     if ($this->GetUserAgent() === null || trim($this->GetUserAgent()) === '' || strpos($this->GetUserAgent(), self::DEFAULT_USER_AGENT) !== false) {
         throw new ValidationException('userAgent', null, sprintf('The property userAgent is required and cannot be ' . 'null, the empty string, or the default [%s]', self::DEFAULT_USER_AGENT));
     }
     if ($this->GetDeveloperToken() === null) {
         throw new ValidationException('developerToken', null, 'developerToken is required and cannot be null.');
     }
 }
Example #2
0
 /**
  * Validates the user and throws a validation error if there are any errors.
  * @throws ValidationException if there are any validation errors
  */
 public function ValidateUser()
 {
     if ($this->GetOAuth2Info() !== NULL) {
         parent::ValidateOAuth2Info();
     } else {
         if ($this->GetAuthToken() == NULL) {
             if (!isset($this->email)) {
                 throw new ValidationException('email', NULL, 'email is required and cannot be NULL.');
             }
             if (!isset($this->password)) {
                 throw new ValidationException('password', NULL, 'password is required and cannot be NULL.');
             }
             // Generate an authToken.
             $this->RegenerateAuthToken();
         }
     }
     if ($this->GetUserAgent() == NULL) {
         throw new ValidationException('userAgent', NULL, 'userAgent is required and cannot be NULL.');
     }
     if ($this->GetDeveloperToken() == NULL) {
         throw new ValidationException('developerToken', NULL, 'developerToken is required and cannot be NULL.');
     }
 }