From d5b2f0c7d4ccb5fa16162fc1f46f8e071ce3df5b Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 27 Apr 2022 22:32:06 +0300 Subject: [PATCH] feat: update paypal OAuth provider --- src/Appwrite/Auth/OAuth2/Paypal.php | 16 +++++++++++++++- src/Appwrite/Auth/OAuth2/Salesforce.php | 8 ++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Auth/OAuth2/Paypal.php b/src/Appwrite/Auth/OAuth2/Paypal.php index f74ce9e9f7..06637b5ec7 100644 --- a/src/Appwrite/Auth/OAuth2/Paypal.php +++ b/src/Appwrite/Auth/OAuth2/Paypal.php @@ -148,7 +148,13 @@ class Paypal extends OAuth2 $user = $this->getUser($accessToken); if (isset($user['emails'])) { - return $user['emails'][0]['value']; + $email = array_filter($user['emails'], function ($email) { + return $email['primary'] === true; + }); + + if (!empty($email)) { + return $email[0]['value']; + } } return ''; @@ -157,12 +163,20 @@ class Paypal extends OAuth2 /** * Check if the OAuth email is verified * + * @link https://developer.paypal.com/docs/api/identity/v1/#userinfo_get + * * @param $accessToken * * @return bool */ public function isEmailVerififed(string $accessToken): bool { + $user = $this->getUser($accessToken); + + if (isset($user['verified_account']) && $user['verified_account'] === true) { + return true; + } + return false; } diff --git a/src/Appwrite/Auth/OAuth2/Salesforce.php b/src/Appwrite/Auth/OAuth2/Salesforce.php index ed640b0951..699cbc7581 100644 --- a/src/Appwrite/Auth/OAuth2/Salesforce.php +++ b/src/Appwrite/Auth/OAuth2/Salesforce.php @@ -151,12 +151,20 @@ class Salesforce extends OAuth2 /** * Check if the OAuth email is verified * + * @link https://help.salesforce.com/s/articleView?id=sf.remoteaccess_using_userinfo_endpoint.htm&type=5 + * * @param $accessToken * * @return bool */ public function isEmailVerififed(string $accessToken): bool { + $user = $this->getUser($accessToken); + + if (isset($user['email_verified']) && $user['email_verified'] === true) { + return true; + } + return false; }