Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GigyaAuthRequest->send() doesn't have proper exception validation #117

Open
stratulat-vladislav opened this issue Nov 18, 2022 · 0 comments

Comments

@stratulat-vladislav
Copy link

stratulat-vladislav commented Nov 18, 2022

I have created a module which depends on gigya/drupal8 and I'm using the following API:

$responce = $helper->getGigyaApiHelper()->sendApiCall('accounts.unsubscribe', ['email' => 'zxc@zxc.zxc']);
// validate $responce and do something else

This call is throwing the following error because there's no such email registered in Gigya and prevents my code to execute "validate $responce and do something else" part:

Drupal\gigya\CmsStarterKit\GSApiException: Invalid parameter value in Drupal\gigya\CmsStarterKit\GigyaAuthRequest->send() (line 49 of /Applications/MAMP/htdocs/di-tjx-ntw-d9/web/modules/contrib/gigya-drupal/gigya/src/CmsStarterKit/GigyaAuthRequest.php).

The error is the actual error response from Gigya, but it shouldn't block me from doing something else.
I believe the code of send() method should look something like this instead:

public function send($timeout = null) {
  try {
    $res = parent::send($timeout);

    if ($res->getErrorCode() == 0)
    {
      return $res;
    }
  }
  catch (Exception $e) {
    if (!empty($res->getData())) { /* Actual error response from Gigya */
      throw new GSApiException($res->getErrorMessage(), $res->getErrorCode(), $res->getResponseText(), $res->getString("callId", "N/A"));
    } else { /* Hard-coded error in PHP SDK, or another failure */
      throw new GSException($res->getErrorMessage(), $res->getErrorCode());
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant