From feb124d16577472804ae7fe596e441fc49ca1e0f Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 27 Apr 2022 22:08:32 +0300 Subject: [PATCH] feat: add method to check for email verification --- src/Appwrite/Auth/OAuth2.php | 38 ++++++++++++------------- src/Appwrite/Auth/OAuth2/Amazon.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Apple.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Bitbucket.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Bitly.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Box.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Discord.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Dropbox.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Facebook.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Github.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Gitlab.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Google.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Linkedin.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Microsoft.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Mock.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Notion.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Paypal.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Salesforce.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Slack.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Spotify.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Stripe.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Tradeshift.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Twitch.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Vk.php | 10 +++++++ src/Appwrite/Auth/OAuth2/WordPress.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Yahoo.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Yammer.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Yandex.php | 10 +++++++ src/Appwrite/Auth/OAuth2/Zoom.php | 10 +++++++ 29 files changed, 299 insertions(+), 19 deletions(-) diff --git a/src/Appwrite/Auth/OAuth2.php b/src/Appwrite/Auth/OAuth2.php index 4eafba761..5ef426383 100644 --- a/src/Appwrite/Auth/OAuth2.php +++ b/src/Appwrite/Auth/OAuth2.php @@ -52,54 +52,54 @@ abstract class OAuth2 /** * @return string */ - abstract public function getName():string; + abstract public function getName(): string; /** * @return string */ - abstract public function getLoginURL():string; + abstract public function getLoginURL(): string; /** * @param string $code * * @return array */ - abstract protected function getTokens(string $code):array; + abstract protected function getTokens(string $code): array; /** * @param string $refreshToken * * @return array */ - abstract public function refreshTokens(string $refreshToken):array; + abstract public function refreshTokens(string $refreshToken): array; /** * @param $accessToken * * @return string */ - abstract public function getUserID(string $accessToken):string; + abstract public function getUserEmail(string $accessToken): string; + + /** + * Is the OAuth email verified? + * + * @return bool + */ + abstract public function isEmailVerififed(): bool; /** * @param $accessToken * * @return string */ - abstract public function getUserEmail(string $accessToken):string; - - /** - * @param $accessToken - * - * @return string - */ - abstract public function getUserName(string $accessToken):string; + abstract public function getUserName(string $accessToken): string; /** * @param $scope * * @return $this */ - protected function addScope(string $scope):OAuth2 + protected function addScope(string $scope): OAuth2 { // Add a scope to the scopes array if it isn't already present if (!\in_array($scope, $this->scopes)) { @@ -111,7 +111,7 @@ abstract class OAuth2 /** * @return array */ - protected function getScopes():array + protected function getScopes(): array { return $this->scopes; } @@ -121,7 +121,7 @@ abstract class OAuth2 * * @return string */ - public function getAccessToken(string $code):string + public function getAccessToken(string $code): string { $tokens = $this->getTokens($code); return $tokens['access_token'] ?? ''; @@ -132,7 +132,7 @@ abstract class OAuth2 * * @return string */ - public function getRefreshToken(string $code):string + public function getRefreshToken(string $code): string { $tokens = $this->getTokens($code); return $tokens['refresh_token'] ?? ''; @@ -143,7 +143,7 @@ abstract class OAuth2 * * @return string */ - public function getAccessTokenExpiry(string $code):string + public function getAccessTokenExpiry(string $code): string { $tokens = $this->getTokens($code); return $tokens['expires_in'] ?? ''; @@ -170,7 +170,7 @@ abstract class OAuth2 * * @return string */ - protected function request(string $method, string $url = '', array $headers = [], string $payload = ''):string + protected function request(string $method, string $url = '', array $headers = [], string $payload = ''): string { $ch = \curl_init($url); diff --git a/src/Appwrite/Auth/OAuth2/Amazon.php b/src/Appwrite/Auth/OAuth2/Amazon.php index 7ec2769c9..7b8cf6dbb 100644 --- a/src/Appwrite/Auth/OAuth2/Amazon.php +++ b/src/Appwrite/Auth/OAuth2/Amazon.php @@ -146,6 +146,16 @@ class Amazon extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Apple.php b/src/Appwrite/Auth/OAuth2/Apple.php index f1ff4b724..c380f7b6a 100644 --- a/src/Appwrite/Auth/OAuth2/Apple.php +++ b/src/Appwrite/Auth/OAuth2/Apple.php @@ -146,6 +146,16 @@ class Apple extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Bitbucket.php b/src/Appwrite/Auth/OAuth2/Bitbucket.php index 74d684c84..5d6c6430d 100644 --- a/src/Appwrite/Auth/OAuth2/Bitbucket.php +++ b/src/Appwrite/Auth/OAuth2/Bitbucket.php @@ -130,6 +130,16 @@ class Bitbucket extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Bitly.php b/src/Appwrite/Auth/OAuth2/Bitly.php index 02a21dc29..a2d72b492 100644 --- a/src/Appwrite/Auth/OAuth2/Bitly.php +++ b/src/Appwrite/Auth/OAuth2/Bitly.php @@ -148,6 +148,16 @@ class Bitly extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Box.php b/src/Appwrite/Auth/OAuth2/Box.php index 80d59e919..a6a1aa27d 100644 --- a/src/Appwrite/Auth/OAuth2/Box.php +++ b/src/Appwrite/Auth/OAuth2/Box.php @@ -147,6 +147,16 @@ class Box extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Discord.php b/src/Appwrite/Auth/OAuth2/Discord.php index dece646e5..7c31c01e7 100644 --- a/src/Appwrite/Auth/OAuth2/Discord.php +++ b/src/Appwrite/Auth/OAuth2/Discord.php @@ -141,6 +141,16 @@ class Discord extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Dropbox.php b/src/Appwrite/Auth/OAuth2/Dropbox.php index f67e10b01..ea6a9c8fc 100644 --- a/src/Appwrite/Auth/OAuth2/Dropbox.php +++ b/src/Appwrite/Auth/OAuth2/Dropbox.php @@ -131,6 +131,16 @@ class Dropbox extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Facebook.php b/src/Appwrite/Auth/OAuth2/Facebook.php index 7759a5404..f4e3c5454 100644 --- a/src/Appwrite/Auth/OAuth2/Facebook.php +++ b/src/Appwrite/Auth/OAuth2/Facebook.php @@ -129,6 +129,16 @@ class Facebook extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Github.php b/src/Appwrite/Auth/OAuth2/Github.php index dddd4a518..4ca85f2b1 100644 --- a/src/Appwrite/Auth/OAuth2/Github.php +++ b/src/Appwrite/Auth/OAuth2/Github.php @@ -137,6 +137,16 @@ class Github extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Gitlab.php b/src/Appwrite/Auth/OAuth2/Gitlab.php index 19ee1363a..39c827389 100644 --- a/src/Appwrite/Auth/OAuth2/Gitlab.php +++ b/src/Appwrite/Auth/OAuth2/Gitlab.php @@ -127,6 +127,16 @@ class Gitlab extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Google.php b/src/Appwrite/Auth/OAuth2/Google.php index 5b3ab938b..b91fd91be 100644 --- a/src/Appwrite/Auth/OAuth2/Google.php +++ b/src/Appwrite/Auth/OAuth2/Google.php @@ -137,6 +137,16 @@ class Google extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Linkedin.php b/src/Appwrite/Auth/OAuth2/Linkedin.php index 2519859a1..577426e96 100644 --- a/src/Appwrite/Auth/OAuth2/Linkedin.php +++ b/src/Appwrite/Auth/OAuth2/Linkedin.php @@ -148,6 +148,16 @@ class Linkedin extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Microsoft.php b/src/Appwrite/Auth/OAuth2/Microsoft.php index ebfd2e4e8..bc4ea55b5 100644 --- a/src/Appwrite/Auth/OAuth2/Microsoft.php +++ b/src/Appwrite/Auth/OAuth2/Microsoft.php @@ -137,6 +137,16 @@ class Microsoft extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Mock.php b/src/Appwrite/Auth/OAuth2/Mock.php index aef92dac2..494674dfb 100644 --- a/src/Appwrite/Auth/OAuth2/Mock.php +++ b/src/Appwrite/Auth/OAuth2/Mock.php @@ -130,6 +130,16 @@ class Mock extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return true; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Notion.php b/src/Appwrite/Auth/OAuth2/Notion.php index 5c117caa3..0a293e3c4 100644 --- a/src/Appwrite/Auth/OAuth2/Notion.php +++ b/src/Appwrite/Auth/OAuth2/Notion.php @@ -134,6 +134,16 @@ class Notion extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Paypal.php b/src/Appwrite/Auth/OAuth2/Paypal.php index 39544c6bd..e4e1bb626 100644 --- a/src/Appwrite/Auth/OAuth2/Paypal.php +++ b/src/Appwrite/Auth/OAuth2/Paypal.php @@ -154,6 +154,16 @@ class Paypal extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Salesforce.php b/src/Appwrite/Auth/OAuth2/Salesforce.php index 04ef1901b..167629a49 100644 --- a/src/Appwrite/Auth/OAuth2/Salesforce.php +++ b/src/Appwrite/Auth/OAuth2/Salesforce.php @@ -148,6 +148,16 @@ class Salesforce extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Slack.php b/src/Appwrite/Auth/OAuth2/Slack.php index 92c210151..f11d9fb65 100644 --- a/src/Appwrite/Auth/OAuth2/Slack.php +++ b/src/Appwrite/Auth/OAuth2/Slack.php @@ -128,6 +128,16 @@ class Slack extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Spotify.php b/src/Appwrite/Auth/OAuth2/Spotify.php index 5c1a43299..ac21b6161 100644 --- a/src/Appwrite/Auth/OAuth2/Spotify.php +++ b/src/Appwrite/Auth/OAuth2/Spotify.php @@ -141,6 +141,16 @@ class Spotify extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Stripe.php b/src/Appwrite/Auth/OAuth2/Stripe.php index 589e6b7b8..35e01c6c8 100644 --- a/src/Appwrite/Auth/OAuth2/Stripe.php +++ b/src/Appwrite/Auth/OAuth2/Stripe.php @@ -141,6 +141,16 @@ class Stripe extends OAuth2 return $user['email'] ?? ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Tradeshift.php b/src/Appwrite/Auth/OAuth2/Tradeshift.php index 38b58432a..b2a9720c8 100644 --- a/src/Appwrite/Auth/OAuth2/Tradeshift.php +++ b/src/Appwrite/Auth/OAuth2/Tradeshift.php @@ -141,6 +141,16 @@ class Tradeshift extends OAuth2 return $user['Username'] ?? ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Twitch.php b/src/Appwrite/Auth/OAuth2/Twitch.php index 0deeb088e..befaeefc1 100644 --- a/src/Appwrite/Auth/OAuth2/Twitch.php +++ b/src/Appwrite/Auth/OAuth2/Twitch.php @@ -140,6 +140,16 @@ class Twitch extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Vk.php b/src/Appwrite/Auth/OAuth2/Vk.php index 5e54b1439..6bcd9b169 100644 --- a/src/Appwrite/Auth/OAuth2/Vk.php +++ b/src/Appwrite/Auth/OAuth2/Vk.php @@ -150,6 +150,16 @@ class Vk extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/WordPress.php b/src/Appwrite/Auth/OAuth2/WordPress.php index 5b957d949..c394a9655 100644 --- a/src/Appwrite/Auth/OAuth2/WordPress.php +++ b/src/Appwrite/Auth/OAuth2/WordPress.php @@ -131,6 +131,16 @@ class WordPress extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Yahoo.php b/src/Appwrite/Auth/OAuth2/Yahoo.php index ffefbe9c6..b6650cb73 100644 --- a/src/Appwrite/Auth/OAuth2/Yahoo.php +++ b/src/Appwrite/Auth/OAuth2/Yahoo.php @@ -161,6 +161,16 @@ class Yahoo extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Yammer.php b/src/Appwrite/Auth/OAuth2/Yammer.php index 6e9f4fb86..97e6f5e13 100644 --- a/src/Appwrite/Auth/OAuth2/Yammer.php +++ b/src/Appwrite/Auth/OAuth2/Yammer.php @@ -130,6 +130,16 @@ class Yammer extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Yandex.php b/src/Appwrite/Auth/OAuth2/Yandex.php index 1f6dda0d1..4aa4a93cf 100644 --- a/src/Appwrite/Auth/OAuth2/Yandex.php +++ b/src/Appwrite/Auth/OAuth2/Yandex.php @@ -144,6 +144,16 @@ class Yandex extends OAuth2 return ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param string $accessToken * diff --git a/src/Appwrite/Auth/OAuth2/Zoom.php b/src/Appwrite/Auth/OAuth2/Zoom.php index 9aa77ceb9..f0f322e57 100644 --- a/src/Appwrite/Auth/OAuth2/Zoom.php +++ b/src/Appwrite/Auth/OAuth2/Zoom.php @@ -126,6 +126,16 @@ class Zoom extends OAuth2 return $response['email'] ?? ''; } + /** + * Is the OAuth email verified? + * + * @return bool + */ + public function isEmailVerififed(): bool + { + return false; + } + /** * @param $accessToken *