From 16c1b0bc2ac34f18e9514341d18a7e478bf6b42d Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Fri, 8 Jul 2022 15:57:51 +0000 Subject: [PATCH 01/17] feat-disqus --- app/config/providers.php | 10 +++ public/images/users/disqus.png | Bin 0 -> 982 bytes src/Appwrite/Auth/OAuth2/Disqus.php | 133 ++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 public/images/users/disqus.png create mode 100644 src/Appwrite/Auth/OAuth2/Disqus.php diff --git a/app/config/providers.php b/app/config/providers.php index e4f01fdf84..4026458162 100644 --- a/app/config/providers.php +++ b/app/config/providers.php @@ -91,6 +91,16 @@ return [ // Ordered by ABC. 'beta' => false, 'mock' => false, ], + 'disqus' => [ + 'name' => 'Disqus', + 'developers' => 'https://disqus.com/api/docs/auth/', + 'icon' => 'icon-disqus', + 'enabled' => true, + 'sandbox' => false, + 'form' => false, + 'beta' => false, + 'mock' => false, + ], 'dropbox' => [ 'name' => 'Dropbox', 'developers' => 'https://www.dropbox.com/developers/documentation', diff --git a/public/images/users/disqus.png b/public/images/users/disqus.png new file mode 100644 index 0000000000000000000000000000000000000000..16b222280cba4299026b1c729e876bdc1979fbd8 GIT binary patch literal 982 zcmV;{11bE8P)faoPdkRpmGqKG1jD58iWiYTIpJaXBc{={}z z47r>w{f+WCEP-5a!Wi#^G*X>u8b?{=O0!W6g2+ zm}KNLXizyMA~gX~q#+xNAoMEG0v7X9|>E44OFhU<|APV zY{07MD`2FBX7UbAV!{&G;N{l}L@M;>=!y*rVQY%P%Zd_2T6~YtAv1-rzch^9#v6uk zHf}wzd=a*A8ODC2fRKh&e)QpyCv3xIID5bWK{^&P{pSY+u{@*+rWawqivE%?lwO2w zw7-$d_A89Pzt#X!`;f6K%OAe}DgdMjBSb%aO$U%?1bI+wAcqOtL`;$UMC}4;LfFaE z3{tpf??DW?`>&e7L?Ns&nM2mjd;|~z5pu4?D?#Mo`je+1vVoD6tB2P?q=J#PD_10u z(lxb;AX38!WkCkVY!pR|W4Tl0e?j^jDg19v#+YTLTMjAW7sxD2eU=|B92s0aypr2U z6e$}C{+8%@F{E(sIf2a`f17Ig+f??3dlM=eB}#`nRQ^g7L48CK#4hJ-L^;PTOskl} zlv`r=Q6)C>u)szg7VwTe>bPSM-T_V*cYsrIkUH`xigl>gMINegjt86Q<3aqOa|5M& z;*o6^e`E_I`-H>i9z^yj$LQd|pOY>GpcKB?q^k{NGG0n8q1e8k0B zmteqGfGG_@FEgtY1ihARq^*C*1?7wQBAeu&XX5BnU_N)P)S(n$~d z91?Hf50+~AhD?!0z9Cbjm2b!tvGNU>AP+@m`N2R29J!7A$LV#c$Cl%`m!~Z=*I3U+ zTPoj=hMxz9gX~_zJL;K8d&-;TQF5N=)p;I@=Xvs;=kb1?&k*u_P?6`;kUSr`ykz-Y zXDqL7&O#p^jn3kqP{oEKiYTIpB8n)Yh$4z8q6iSb0n@ANQuqQmGynhq07*qoM6N<$ Ef|gpxVE_OC literal 0 HcmV?d00001 diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php new file mode 100644 index 0000000000..09523006b2 --- /dev/null +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -0,0 +1,133 @@ +endpoint . 'oauth/2.0/authorize/?' . + \http_build_query([ + 'response_type' => 'code', + 'client_id' => $this->appID, + 'state' => \json_encode($this->state), + 'redirect_uri' => $this->callback, + 'scope' => \implode(' ', $this->getScopes()) + ]); + + return $url; + } + + protected function getTokens(string $code): array + { + if (empty($this->tokens)) { + $this->tokens = \json_decode($this->request( + 'POST', + $this->endpoint . 'oauth/2.0/access_token/', + ["Content-Type: application/x-www-form-urlencoded"], + \http_build_query([ + 'grant_type' => 'authorization_code', + "client_id" => $this->appID, + "client_secret" => $this->appSecret, + "redirect_uri" => $this->callback, + 'code' => $code, + 'scope' => \implode(' ', $this->getScopes()), + ]) + ), true); + } + return $this->tokens; + } + + public function refreshTokens(string $refreshToken): array + { + $this->tokens = \json_decode($this->request( + 'POST', + $this->endpoint . 'oauth/2.0/access_token/?', + ['Content-Type: application/x-www-form-urlencoded'], + \http_build_query([ + 'grant_type' => 'refresh_token', + 'refresh_token' => $refreshToken, + 'client_id' => $this->appID, + 'client_secret' => $this->appSecret, + ]) + ), true); + + if (empty($this->tokens['refresh_token'])) { + $this->tokens['refresh_token'] = $refreshToken; + } + + + return $this->tokens; + } + + public function getUserID(string $accessToken): string + { + $user = $this->getUser($accessToken); + + $userId = $user["id"]; + + return $userId; + } + + public function getUserEmail(string $accessToken): string + { + $user = $this->getUser($accessToken); + + $userEmail = $user["email"]; + + return $userEmail; + } + + public function isEmailVerified(string $accessToken): bool + { + $user = $this->getUser($accessToken); + + $isVerified = "[USER VERIFICATION STATUS]"; + + return $isVerified; + } + + public function getUserName(string $accessToken): string + { + $user = $this->getUser($accessToken); + + $username = $user["username"] ?? ''; + + return $username; + } + + protected function getUser(string $accessToken): array + { + if (empty($this->user)) { + $user = $this->request( + 'GET', + $this->endpoint . 'users/details.json?' . \http_build_query([ + 'access_token' => $accessToken, + 'api_key' => $this->appId, + 'api_secret' => $this->appSecret + ]), + ); + $this->user = \json_decode($user, true); + } + + return $this->user; + } +} From 2d8ddfedfa8437cbf7653964b8b5624bc015b32c Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Fri, 8 Jul 2022 16:02:24 +0000 Subject: [PATCH 02/17] update comment --- src/Appwrite/Auth/OAuth2/Disqus.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php index 09523006b2..20fa28f998 100644 --- a/src/Appwrite/Auth/OAuth2/Disqus.php +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -5,7 +5,7 @@ namespace Appwrite\Auth\OAuth2; use Appwrite\Auth\OAuth2; // Reference Material -// [DOCS FROM OAUTH PROVIDER] +// https://disqus.com/api/docs/auth/ class Disqus extends OAuth2 { From a54151fb8659f4a9456f485d0927a12d20e2b65a Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Fri, 8 Jul 2022 18:18:04 +0000 Subject: [PATCH 03/17] add php intellisense --- .gitpod.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitpod.yml b/.gitpod.yml index 5f8eac91e1..a63c07bad2 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -22,6 +22,7 @@ ports: vscode: extensions: - ms-azuretools.vscode-docker + - zobo.php-intellisense github: # https://www.gitpod.io/docs/prebuilds#github-specific-configuration From 4adc0eb563ad386835cf9dbd329c31e6edf2be78 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Fri, 8 Jul 2022 18:18:40 +0000 Subject: [PATCH 04/17] fix urls get user method --- src/Appwrite/Auth/OAuth2/Disqus.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php index 20fa28f998..899c67a073 100644 --- a/src/Appwrite/Auth/OAuth2/Disqus.php +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -30,7 +30,7 @@ class Disqus extends OAuth2 'client_id' => $this->appID, 'state' => \json_encode($this->state), 'redirect_uri' => $this->callback, - 'scope' => \implode(' ', $this->getScopes()) + 'scope' => \implode(',', $this->getScopes()) ]); return $url; @@ -82,7 +82,7 @@ class Disqus extends OAuth2 { $user = $this->getUser($accessToken); - $userId = $user["id"]; + $userId = $user["response"]["id"]; return $userId; } @@ -91,7 +91,7 @@ class Disqus extends OAuth2 { $user = $this->getUser($accessToken); - $userEmail = $user["email"]; + $userEmail = $user["response"]["email"]; return $userEmail; } @@ -100,7 +100,7 @@ class Disqus extends OAuth2 { $user = $this->getUser($accessToken); - $isVerified = "[USER VERIFICATION STATUS]"; + $isVerified = $user["response"]["isAnonymous"]; return $isVerified; } @@ -109,7 +109,7 @@ class Disqus extends OAuth2 { $user = $this->getUser($accessToken); - $username = $user["username"] ?? ''; + $username = $user["response"]["username"] ?? ''; return $username; } @@ -119,9 +119,9 @@ class Disqus extends OAuth2 if (empty($this->user)) { $user = $this->request( 'GET', - $this->endpoint . 'users/details.json?' . \http_build_query([ + $this->endpoint . '3.0/users/details.json?' . \http_build_query([ 'access_token' => $accessToken, - 'api_key' => $this->appId, + 'api_key' => $this->appID, 'api_secret' => $this->appSecret ]), ); From 163a013e1f1070eac3f9253a8c1450093e8de0e9 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Mon, 11 Jul 2022 11:15:53 +0000 Subject: [PATCH 05/17] fix double quotes to single quotes for strings --- src/Appwrite/Auth/OAuth2/Disqus.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php index 899c67a073..63aea1e7ed 100644 --- a/src/Appwrite/Auth/OAuth2/Disqus.php +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -13,13 +13,13 @@ class Disqus extends OAuth2 protected array $user = []; protected array $tokens = []; protected array $scopes = [ - "read", - "email", + 'read', + 'email', ]; public function getName(): string { - return "disqus"; + return 'disqus'; } public function getLoginURL(): string @@ -42,12 +42,12 @@ class Disqus extends OAuth2 $this->tokens = \json_decode($this->request( 'POST', $this->endpoint . 'oauth/2.0/access_token/', - ["Content-Type: application/x-www-form-urlencoded"], + ['Content-Type: application/x-www-form-urlencoded'], \http_build_query([ 'grant_type' => 'authorization_code', - "client_id" => $this->appID, - "client_secret" => $this->appSecret, - "redirect_uri" => $this->callback, + 'client_id' => $this->appID, + 'client_secret' => $this->appSecret, + 'redirect_uri' => $this->callback, 'code' => $code, 'scope' => \implode(' ', $this->getScopes()), ]) @@ -82,7 +82,7 @@ class Disqus extends OAuth2 { $user = $this->getUser($accessToken); - $userId = $user["response"]["id"]; + $userId = $user['response']['id']; return $userId; } @@ -91,7 +91,7 @@ class Disqus extends OAuth2 { $user = $this->getUser($accessToken); - $userEmail = $user["response"]["email"]; + $userEmail = $user['response']['email']; return $userEmail; } @@ -100,7 +100,7 @@ class Disqus extends OAuth2 { $user = $this->getUser($accessToken); - $isVerified = $user["response"]["isAnonymous"]; + $isVerified = $user['response']['isAnonymous']; return $isVerified; } @@ -109,7 +109,7 @@ class Disqus extends OAuth2 { $user = $this->getUser($accessToken); - $username = $user["response"]["username"] ?? ''; + $username = $user['response']['username'] ?? ''; return $username; } From 9f5fec71359f32c383b1f6469592d9113c340e7a Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Mon, 11 Jul 2022 11:22:40 +0000 Subject: [PATCH 06/17] emailVerified should return false now --- src/Appwrite/Auth/OAuth2/Disqus.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php index 63aea1e7ed..3ce07c1f49 100644 --- a/src/Appwrite/Auth/OAuth2/Disqus.php +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -100,9 +100,12 @@ class Disqus extends OAuth2 { $user = $this->getUser($accessToken); - $isVerified = $user['response']['isAnonymous']; + // Look out for the change in their enpoint. + // It's in Beta so they may provide a parameter in the future. + // https://disqus.com/api/docs/users/details/ + // $isVerified = $user['response']['isAnonymous']; - return $isVerified; + return false; } public function getUserName(string $accessToken): string From 3ee7ccff480962c1d00ac7857a31ff31284a5451 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Mon, 11 Jul 2022 11:27:17 +0000 Subject: [PATCH 07/17] commented unused code --- src/Appwrite/Auth/OAuth2/Disqus.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php index 3ce07c1f49..e0008f2560 100644 --- a/src/Appwrite/Auth/OAuth2/Disqus.php +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -98,7 +98,7 @@ class Disqus extends OAuth2 public function isEmailVerified(string $accessToken): bool { - $user = $this->getUser($accessToken); + // $user = $this->getUser($accessToken); // Look out for the change in their enpoint. // It's in Beta so they may provide a parameter in the future. From 122a59c7237b0b0788931e19f2fe0af4be77ab1f Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi <62933155+2002Bishwajeet@users.noreply.github.com> Date: Mon, 11 Jul 2022 17:55:06 +0530 Subject: [PATCH 08/17] Update src/Appwrite/Auth/OAuth2/Disqus.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matej Bačo --- src/Appwrite/Auth/OAuth2/Disqus.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php index e0008f2560..d9b98bd32e 100644 --- a/src/Appwrite/Auth/OAuth2/Disqus.php +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -73,8 +73,6 @@ class Disqus extends OAuth2 if (empty($this->tokens['refresh_token'])) { $this->tokens['refresh_token'] = $refreshToken; } - - return $this->tokens; } From d96be650e4757a304af208d0c3471bc7c1587398 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Mon, 11 Jul 2022 12:40:17 +0000 Subject: [PATCH 09/17] change to name --- composer.lock | 12 ++++++------ src/Appwrite/Auth/OAuth2/Disqus.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.lock b/composer.lock index 9d29bc8ac7..4e7a77a447 100644 --- a/composer.lock +++ b/composer.lock @@ -2051,16 +2051,16 @@ }, { "name": "utopia-php/database", - "version": "0.18.6", + "version": "0.18.7", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "e9e163642546343267c2fe0ee90016a4a0230b4a" + "reference": "d542ee433f1a545d926ffaf707bdf952dc18a52e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/e9e163642546343267c2fe0ee90016a4a0230b4a", - "reference": "e9e163642546343267c2fe0ee90016a4a0230b4a", + "url": "https://api.github.com/repos/utopia-php/database/zipball/d542ee433f1a545d926ffaf707bdf952dc18a52e", + "reference": "d542ee433f1a545d926ffaf707bdf952dc18a52e", "shasum": "" }, "require": { @@ -2109,9 +2109,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.18.6" + "source": "https://github.com/utopia-php/database/tree/0.18.7" }, - "time": "2022-06-27T17:28:05+00:00" + "time": "2022-07-11T10:20:33+00:00" }, { "name": "utopia-php/domains", diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php index d9b98bd32e..5d9c9feace 100644 --- a/src/Appwrite/Auth/OAuth2/Disqus.php +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -110,7 +110,7 @@ class Disqus extends OAuth2 { $user = $this->getUser($accessToken); - $username = $user['response']['username'] ?? ''; + $username = $user['response']['name'] ?? ''; return $username; } From 68616957ab5342e08250acb98c8551102fbe12d1 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Mon, 11 Jul 2022 13:32:46 +0000 Subject: [PATCH 10/17] tiny code quality --- src/Appwrite/Auth/OAuth2/Disqus.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php index 5d9c9feace..533b4c3c7f 100644 --- a/src/Appwrite/Auth/OAuth2/Disqus.php +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -80,7 +80,7 @@ class Disqus extends OAuth2 { $user = $this->getUser($accessToken); - $userId = $user['response']['id']; + $userId = $user['id']; return $userId; } @@ -89,7 +89,7 @@ class Disqus extends OAuth2 { $user = $this->getUser($accessToken); - $userEmail = $user['response']['email']; + $userEmail = $user['email']; return $userEmail; } @@ -101,7 +101,7 @@ class Disqus extends OAuth2 // Look out for the change in their enpoint. // It's in Beta so they may provide a parameter in the future. // https://disqus.com/api/docs/users/details/ - // $isVerified = $user['response']['isAnonymous']; + // $isVerified = $user['isAnonymous']; return false; } @@ -110,7 +110,7 @@ class Disqus extends OAuth2 { $user = $this->getUser($accessToken); - $username = $user['response']['name'] ?? ''; + $username = $user['name'] ?? ''; return $username; } @@ -126,7 +126,7 @@ class Disqus extends OAuth2 'api_secret' => $this->appSecret ]), ); - $this->user = \json_decode($user, true); + $this->user = \json_decode($user, true)['response']; } return $this->user; From dab0a8ec274036f0b6fed95ab1c37b743324b07a Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi <62933155+2002Bishwajeet@users.noreply.github.com> Date: Fri, 5 Aug 2022 21:25:21 +0530 Subject: [PATCH 11/17] Update src/Appwrite/Auth/OAuth2/Disqus.php Co-authored-by: Christy Jacob --- src/Appwrite/Auth/OAuth2/Disqus.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php index 533b4c3c7f..dcbde880b4 100644 --- a/src/Appwrite/Auth/OAuth2/Disqus.php +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -22,6 +22,9 @@ class Disqus extends OAuth2 return 'disqus'; } + /** + * @return string + */ public function getLoginURL(): string { $url = $this->endpoint . 'oauth/2.0/authorize/?' . From 6fdf578919df8407e9c4cf65352f11ee22043193 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi <62933155+2002Bishwajeet@users.noreply.github.com> Date: Fri, 5 Aug 2022 21:25:34 +0530 Subject: [PATCH 12/17] Update src/Appwrite/Auth/OAuth2/Disqus.php Co-authored-by: Christy Jacob --- src/Appwrite/Auth/OAuth2/Disqus.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php index dcbde880b4..b783378cdc 100644 --- a/src/Appwrite/Auth/OAuth2/Disqus.php +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -99,7 +99,6 @@ class Disqus extends OAuth2 public function isEmailVerified(string $accessToken): bool { - // $user = $this->getUser($accessToken); // Look out for the change in their enpoint. // It's in Beta so they may provide a parameter in the future. From 9cd10686bbec0441f26454bb8866da9e30a51c85 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi <62933155+2002Bishwajeet@users.noreply.github.com> Date: Fri, 5 Aug 2022 21:25:41 +0530 Subject: [PATCH 13/17] Update src/Appwrite/Auth/OAuth2/Disqus.php Co-authored-by: Christy Jacob --- src/Appwrite/Auth/OAuth2/Disqus.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php index b783378cdc..0a2c7a808a 100644 --- a/src/Appwrite/Auth/OAuth2/Disqus.php +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -103,7 +103,6 @@ class Disqus extends OAuth2 // Look out for the change in their enpoint. // It's in Beta so they may provide a parameter in the future. // https://disqus.com/api/docs/users/details/ - // $isVerified = $user['isAnonymous']; return false; } From 999962d161150323ea77c05bdd309b8fc8b04ac4 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Fri, 5 Aug 2022 16:09:38 +0000 Subject: [PATCH 14/17] add comments denoting return type and parameters if any --- composer.lock | 2 +- src/Appwrite/Auth/OAuth2/Disqus.php | 53 +++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index 93b8455cac..bce5b90d88 100644 --- a/composer.lock +++ b/composer.lock @@ -5370,5 +5370,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php index 0a2c7a808a..5dfe9d0084 100644 --- a/src/Appwrite/Auth/OAuth2/Disqus.php +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -9,14 +9,32 @@ use Appwrite\Auth\OAuth2; class Disqus extends OAuth2 { + /** + * @var string + */ private string $endpoint = 'https://disqus.com/api/'; + + /** + * @var array + */ protected array $user = []; + + /** + * @var array + */ protected array $tokens = []; + + /** + * @var array + */ protected array $scopes = [ 'read', 'email', ]; + /** + * @return string + */ public function getName(): string { return 'disqus'; @@ -39,6 +57,11 @@ class Disqus extends OAuth2 return $url; } + /** + * @param string $code + * + * @return array + */ protected function getTokens(string $code): array { if (empty($this->tokens)) { @@ -59,6 +82,11 @@ class Disqus extends OAuth2 return $this->tokens; } + /** + * @param string $refreshToken + * + * @return array + */ public function refreshTokens(string $refreshToken): array { $this->tokens = \json_decode($this->request( @@ -79,6 +107,11 @@ class Disqus extends OAuth2 return $this->tokens; } + /** + * @param string $token + * + * @return string + */ public function getUserID(string $accessToken): string { $user = $this->getUser($accessToken); @@ -88,6 +121,11 @@ class Disqus extends OAuth2 return $userId; } + /** + * @param string $accessToken + * + * @return string + */ public function getUserEmail(string $accessToken): string { $user = $this->getUser($accessToken); @@ -97,6 +135,11 @@ class Disqus extends OAuth2 return $userEmail; } + /** + * @param string $accessToken + * + * @return bool + */ public function isEmailVerified(string $accessToken): bool { @@ -107,6 +150,11 @@ class Disqus extends OAuth2 return false; } + /** + * @param string $accessToken + * + * @return string + */ public function getUserName(string $accessToken): string { $user = $this->getUser($accessToken); @@ -116,6 +164,11 @@ class Disqus extends OAuth2 return $username; } + /** + * @param string $accessToken + * + * @return array + */ protected function getUser(string $accessToken): array { if (empty($this->user)) { From 93466d9a66c2dc658f5e99d37636cca411f7dc6f Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Fri, 5 Aug 2022 16:12:00 +0000 Subject: [PATCH 15/17] resized image 100x100 --- public/images/users/disqus.png | Bin 982 -> 2769 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/public/images/users/disqus.png b/public/images/users/disqus.png index 16b222280cba4299026b1c729e876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 Subject: [PATCH 16/17] remove whitespace --- src/Appwrite/Auth/OAuth2/Linkedin.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Appwrite/Auth/OAuth2/Linkedin.php b/src/Appwrite/Auth/OAuth2/Linkedin.php index 8cf9b8aff7..340cab2df0 100644 --- a/src/Appwrite/Auth/OAuth2/Linkedin.php +++ b/src/Appwrite/Auth/OAuth2/Linkedin.php @@ -80,7 +80,6 @@ class Linkedin extends OAuth2 ]) ), true); } - return $this->tokens; } @@ -107,7 +106,6 @@ class Linkedin extends OAuth2 if (empty($this->tokens['refresh_token'])) { $this->tokens['refresh_token'] = $refreshToken; } - return $this->tokens; } From f4c5b4c11d19bd55ec809f59858ecfc83cf3e8a8 Mon Sep 17 00:00:00 2001 From: Bishwajeet Parhi Date: Mon, 8 Aug 2022 12:44:11 +0000 Subject: [PATCH 17/17] lints fixed --- src/Appwrite/Auth/OAuth2/Disqus.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Appwrite/Auth/OAuth2/Disqus.php b/src/Appwrite/Auth/OAuth2/Disqus.php index 5dfe9d0084..58b7f48914 100644 --- a/src/Appwrite/Auth/OAuth2/Disqus.php +++ b/src/Appwrite/Auth/OAuth2/Disqus.php @@ -59,7 +59,7 @@ class Disqus extends OAuth2 /** * @param string $code - * + * * @return array */ protected function getTokens(string $code): array @@ -84,7 +84,7 @@ class Disqus extends OAuth2 /** * @param string $refreshToken - * + * * @return array */ public function refreshTokens(string $refreshToken): array @@ -109,7 +109,7 @@ class Disqus extends OAuth2 /** * @param string $token - * + * * @return string */ public function getUserID(string $accessToken): string @@ -123,7 +123,7 @@ class Disqus extends OAuth2 /** * @param string $accessToken - * + * * @return string */ public function getUserEmail(string $accessToken): string @@ -137,7 +137,7 @@ class Disqus extends OAuth2 /** * @param string $accessToken - * + * * @return bool */ public function isEmailVerified(string $accessToken): bool @@ -152,7 +152,7 @@ class Disqus extends OAuth2 /** * @param string $accessToken - * + * * @return string */ public function getUserName(string $accessToken): string @@ -166,7 +166,7 @@ class Disqus extends OAuth2 /** * @param string $accessToken - * + * * @return array */ protected function getUser(string $accessToken): array