1
0
Fork 0
mirror of synced 2024-06-29 11:40:45 +12:00

fix: improve typing and nullish values

This commit is contained in:
Torsten Dittmann 2022-05-12 17:56:20 +02:00
parent 726b71ae3b
commit 05c37c8a28
32 changed files with 712 additions and 1006 deletions

View file

@ -7,27 +7,27 @@ abstract class OAuth2
/**
* @var string
*/
protected $appID;
protected string $appID;
/**
* @var string
*/
protected $appSecret;
protected string $appSecret;
/**
* @var string
*/
protected $callback;
protected string $callback;
/**
* @var array
*/
protected $state;
protected array $state;
/**
* @var array
*/
protected $scopes;
protected array $scopes;
/**
* OAuth2 constructor.
@ -74,7 +74,7 @@ abstract class OAuth2
abstract public function refreshTokens(string $refreshToken): array;
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -83,14 +83,14 @@ abstract class OAuth2
/**
* Check if the OAuth email is verified
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
abstract public function isEmailVerified(string $accessToken): bool;
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -107,6 +107,7 @@ abstract class OAuth2
if (!\in_array($scope, $this->scopes)) {
$this->scopes[] = $scope;
}
return $this;
}
@ -126,6 +127,7 @@ abstract class OAuth2
public function getAccessToken(string $code): string
{
$tokens = $this->getTokens($code);
return $tokens['access_token'] ?? '';
}
@ -137,6 +139,7 @@ abstract class OAuth2
public function getRefreshToken(string $code): string
{
$tokens = $this->getTokens($code);
return $tokens['refresh_token'] ?? '';
}
@ -148,6 +151,7 @@ abstract class OAuth2
public function getAccessTokenExpiry(string $code): string
{
$tokens = $this->getTokens($code);
return $tokens['expires_in'] ?? '';
}

View file

@ -14,17 +14,17 @@ class Amazon extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
"profile"
];
@ -37,7 +37,7 @@ class Amazon extends OAuth2
}
/**
* @param $state
* @param string $state
*
* @return array
*/
@ -123,11 +123,7 @@ class Amazon extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['user_id'])) {
return $user['user_id'];
}
return '';
return $user['user_id'] ?? '';
}
/**
@ -139,11 +135,7 @@ class Amazon extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -151,7 +143,7 @@ class Amazon extends OAuth2
*
* If present, the email is verified. This was verfied through a manual Amazon sign up process
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -171,11 +163,7 @@ class Amazon extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**

View file

@ -13,17 +13,17 @@ class Apple extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
"name",
"email"
];
@ -31,7 +31,7 @@ class Apple extends OAuth2
/**
* @var array
*/
protected $claims = [];
protected array $claims = [];
/**
* @return string
@ -122,11 +122,7 @@ class Apple extends OAuth2
*/
public function getUserID(string $accessToken): string
{
if (isset($this->claims['sub']) && !empty($this->claims['sub'])) {
return $this->claims['sub'];
}
return '';
return $this->claims['sub'] ?? '';
}
/**
@ -136,11 +132,7 @@ class Apple extends OAuth2
*/
public function getUserEmail(string $accessToken): string
{
if (isset($this->claims['email']) && !empty($this->claims['email'])) {
return $this->claims['email'];
}
return '';
return $this->claims['email'] ?? '';
}
/**
@ -148,13 +140,13 @@ class Apple extends OAuth2
*
* @link https://developer.apple.com/forums/thread/121411
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
public function isEmailVerified(string $accessToken): bool
{
if (isset($this->claims['email_verified']) && $this->claims['email_verified'] === 'true') {
if ($this->claims['email_verified'] ?? false) {
return true;
}
@ -168,10 +160,12 @@ class Apple extends OAuth2
*/
public function getUserName(string $accessToken): string
{
if (isset($this->claims['email']) &&
if (
isset($this->claims['email']) &&
!empty($this->claims['email']) &&
isset($this->claims['email_verified']) &&
$this->claims['email_verified'] === 'true') {
$this->claims['email_verified'] === 'true'
) {
return $this->claims['email'];
}

View file

@ -12,7 +12,7 @@ class Auth0 extends OAuth2
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'openid',
'profile',
'email',
@ -22,12 +22,12 @@ class Auth0 extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @return string
@ -115,11 +115,7 @@ class Auth0 extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['sub'])) {
return $user['sub'];
}
return '';
return $user['sub'] ?? '';
}
/**
@ -131,11 +127,7 @@ class Auth0 extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -143,7 +135,7 @@ class Auth0 extends OAuth2
*
* @link https://auth0.com/docs/api/authentication?javascript#user-profile
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -151,7 +143,7 @@ class Auth0 extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email_verified']) && $user['email_verified'] === true) {
if ($user['email_verified'] ?? false) {
return true;
}
@ -167,11 +159,7 @@ class Auth0 extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**
@ -199,7 +187,7 @@ class Auth0 extends OAuth2
{
$secret = $this->getAppSecret();
return (isset($secret['clientSecret'])) ? $secret['clientSecret'] : '';
return $secret['clientSecret'] ?? '';
}
/**
@ -210,7 +198,8 @@ class Auth0 extends OAuth2
protected function getAuth0Domain(): string
{
$secret = $this->getAppSecret();
return (isset($secret['auth0Domain'])) ? $secret['auth0Domain'] : '';
return $secret['auth0Domain'] ?? '';
}
/**

View file

@ -12,17 +12,17 @@ class Bitbucket extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [];
protected array $scopes = [];
/**
* @return string
@ -107,11 +107,7 @@ class Bitbucket extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['uuid'])) {
return $user['uuid'];
}
return '';
return $user['uuid'] ?? '';
}
/**
@ -123,17 +119,13 @@ class Bitbucket extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
* Check if the OAuth email is verified
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -141,7 +133,7 @@ class Bitbucket extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['is_confirmed']) && $user['is_confirmed'] === true) {
if ($user['is_confirmed'] ?? false) {
return true;
}
@ -157,11 +149,7 @@ class Bitbucket extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['display_name'])) {
return $user['display_name'];
}
return '';
return $user['display_name'] ?? '';
}
/**
@ -186,7 +174,6 @@ class Bitbucket extends OAuth2
}
}
}
}
return $this->user;
}

View file

@ -3,7 +3,6 @@
namespace Appwrite\Auth\OAuth2;
use Appwrite\Auth\OAuth2;
use Utopia\Exception;
// Reference Material
// https://dev.bitly.com/v4_documentation.html
@ -14,27 +13,27 @@ class Bitly extends OAuth2
/**
* @var string
*/
private $endpoint = 'https://bitly.com/oauth/';
private string $endpoint = 'https://bitly.com/oauth/';
/**
* @var string
*/
private $resourceEndpoint = 'https://api-ssl.bitly.com/';
private string $resourceEndpoint = 'https://api-ssl.bitly.com/';
/**
* @var array
*/
protected $scopes = [];
protected array $scopes = [];
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @return string
@ -117,7 +116,7 @@ class Bitly extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -125,15 +124,11 @@ class Bitly extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['login'])) {
return $user['login'];
}
return '';
return $user['login'] ?? '';
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -157,7 +152,7 @@ class Bitly extends OAuth2
*
* @link https://dev.bitly.com/api-reference#getUser
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -167,7 +162,7 @@ class Bitly extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -175,11 +170,7 @@ class Bitly extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**
@ -198,7 +189,6 @@ class Bitly extends OAuth2
$this->user = \json_decode($this->request('GET', $this->resourceEndpoint . "v4/user", $headers), true);
}
return $this->user;
}
}

View file

@ -12,27 +12,27 @@ class Box extends OAuth2
/**
* @var string
*/
private $endpoint = 'https://account.box.com/api/oauth2/';
private string $endpoint = 'https://account.box.com/api/oauth2/';
/**
* @var string
*/
private $resourceEndpoint = 'https://api.box.com/2.0/';
private string $resourceEndpoint = 'https://api.box.com/2.0/';
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'manage_app_users',
];
@ -124,11 +124,7 @@ class Box extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['id'])) {
return $user['id'];
}
return '';
return $user['id'] ?? '';
}
/**
@ -140,11 +136,7 @@ class Box extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['login'])) {
return $user['login'];
}
return '';
return $user['login'] ?? '';
}
/**
@ -152,7 +144,7 @@ class Box extends OAuth2
*
* If present, the email is verified. This was verfied through a manual Box sign up process
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -172,11 +164,7 @@ class Box extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**

View file

@ -12,22 +12,22 @@ class Discord extends OAuth2
/**
* @var string
*/
private $endpoint = 'https://discordapp.com/api';
private string $endpoint = 'https://discordapp.com/api';
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'identify',
'email'
];
@ -118,11 +118,7 @@ class Discord extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['id'])) {
return $user['id'];
}
return '';
return $user['id'] ?? '';
}
/**
@ -134,11 +130,7 @@ class Discord extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -146,7 +138,7 @@ class Discord extends OAuth2
*
* @link https://discord.com/developers/docs/resources/user
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -154,7 +146,7 @@ class Discord extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['verified']) && $user['verified'] === true) {
if ($user['verified'] ?? false) {
return true;
}
@ -170,11 +162,7 @@ class Discord extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['username'])) {
return $user['username'];
}
return '';
return $user['username'] ?? '';
}
/**

View file

@ -13,17 +13,17 @@ class Dropbox extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [];
protected array $scopes = [];
/**
* @return string
@ -108,11 +108,7 @@ class Dropbox extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['account_id'])) {
return $user['account_id'];
}
return '';
return $user['account_id'] ?? '';
}
/**
@ -124,11 +120,7 @@ class Dropbox extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -136,7 +128,7 @@ class Dropbox extends OAuth2
*
* @link https://www.dropbox.com/developers/documentation/http/documentation#users-get_current_account
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -144,7 +136,7 @@ class Dropbox extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email_verified']) && $user['email_verified'] === true) {
if ($user['email_verified'] ?? false) {
return true;
}
@ -160,11 +152,7 @@ class Dropbox extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name']['display_name'];
}
return '';
return $user['name']['display_name'] ?? '';
}
/**

View file

@ -3,29 +3,28 @@
namespace Appwrite\Auth\OAuth2;
use Appwrite\Auth\OAuth2;
use Utopia\Exception;
class Facebook extends OAuth2
{
/**
* @var string
*/
protected $version = 'v2.8';
protected string $version = 'v2.8';
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'email'
];
@ -106,11 +105,7 @@ class Facebook extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['id'])) {
return $user['id'];
}
return '';
return $user['id'] ?? '';
}
/**
@ -122,11 +117,7 @@ class Facebook extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -134,7 +125,7 @@ class Facebook extends OAuth2
*
* If present, the email is verified. This was verfied through a manual Facebook sign up process
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -154,11 +145,7 @@ class Facebook extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**

View file

@ -3,24 +3,23 @@
namespace Appwrite\Auth\OAuth2;
use Appwrite\Auth\OAuth2;
use Utopia\Exception;
class Github extends OAuth2
{
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'user:email',
];
@ -104,7 +103,7 @@ class Github extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -112,15 +111,11 @@ class Github extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['id'])) {
return $user['id'];
}
return '';
return $user['id'] ?? '';
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -128,11 +123,7 @@ class Github extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -140,7 +131,7 @@ class Github extends OAuth2
*
* @link https://docs.github.com/en/rest/users/emails#list-email-addresses-for-the-authenticated-user
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -148,7 +139,7 @@ class Github extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['verified']) && $user['verified'] !== null) {
if ($user['verified'] ?? false) {
return true;
}
@ -156,7 +147,7 @@ class Github extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -164,11 +155,7 @@ class Github extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**

View file

@ -12,17 +12,17 @@ class Gitlab extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'read_user'
];
@ -120,11 +120,7 @@ class Gitlab extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -132,7 +128,7 @@ class Gitlab extends OAuth2
*
* @link https://docs.gitlab.com/ee/api/users.html#list-current-user-for-normal-users
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -140,7 +136,7 @@ class Gitlab extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['confirmed_at']) && $user['confirmed_at'] !== null) {
if ($user['confirmed_at'] ?? false) {
return true;
}
@ -156,11 +152,7 @@ class Gitlab extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**

View file

@ -14,12 +14,12 @@ class Google extends OAuth2
/**
* @var string
*/
protected $version = 'v4';
protected string $version = 'v4';
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'https://www.googleapis.com/auth/userinfo.email',
'https://www.googleapis.com/auth/userinfo.profile',
'openid'
@ -28,12 +28,12 @@ class Google extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @return string
@ -114,11 +114,7 @@ class Google extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['id'])) {
return $user['id'];
}
return '';
return $user['id'] ?? '';
}
/**
@ -130,11 +126,7 @@ class Google extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -142,7 +134,7 @@ class Google extends OAuth2
*
* @link https://www.oauth.com/oauth2-servers/signing-in-with-google/verifying-the-user-info/
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -150,7 +142,7 @@ class Google extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email_verified']) && $user['email_verified'] === true) {
if ($user['email_verified'] ?? false) {
return true;
}
@ -166,11 +158,7 @@ class Google extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**

View file

@ -9,17 +9,17 @@ class Linkedin extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'r_liteprofile',
'r_emailaddress',
];
@ -112,7 +112,7 @@ class Linkedin extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -120,15 +120,11 @@ class Linkedin extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['id'])) {
return $user['id'];
}
return '';
return $user['id'] ?? '';
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -136,16 +132,7 @@ class Linkedin extends OAuth2
{
$email = \json_decode($this->request('GET', 'https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))', ['Authorization: Bearer ' . \urlencode($accessToken)]), true);
if (
isset($email['elements']) &&
isset($email['elements'][0]) &&
isset($email['elements'][0]['handle~']) &&
isset($email['elements'][0]['handle~']['emailAddress'])
) {
return $email['elements'][0]['handle~']['emailAddress'];
}
return '';
return $email['elements'][0]['handle~']['emailAddress'] ?? '';
}
/**
@ -153,7 +140,7 @@ class Linkedin extends OAuth2
*
* If present, the email is verified. This was verfied through a manual Linkedin sign up process
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -165,7 +152,7 @@ class Linkedin extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/

View file

@ -13,17 +13,17 @@ class Microsoft extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'offline_access',
'user.read'
];
@ -114,11 +114,7 @@ class Microsoft extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['id'])) {
return $user['id'];
}
return '';
return $user['id'] ?? '';
}
/**
@ -130,11 +126,7 @@ class Microsoft extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['userPrincipalName'])) {
return $user['userPrincipalName'];
}
return '';
return $user['userPrincipalName'] ?? '';
}
/**
@ -142,7 +134,7 @@ class Microsoft extends OAuth2
*
* If present, the email is verified. This was verfied through a manual Microsoft sign up process
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -162,11 +154,7 @@ class Microsoft extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['displayName'])) {
return $user['displayName'];
}
return '';
return $user['displayName'] ?? '';
}
/**
@ -208,7 +196,8 @@ class Microsoft extends OAuth2
protected function getClientSecret(): string
{
$secret = $this->getAppSecret();
return (isset($secret['clientSecret'])) ? $secret['clientSecret'] : '';
return $secret['clientSecret'] ?? '';
}
/**
@ -219,6 +208,7 @@ class Microsoft extends OAuth2
protected function getTenantID(): string
{
$secret = $this->getAppSecret();
return (isset($secret['tenantID'])) ? $secret['tenantID'] : 'common';
return $secret['tenantID'] ?? 'common';
}
}

View file

@ -10,24 +10,24 @@ class Mock extends OAuth2
/**
* @var string
*/
protected $version = 'v1';
protected string $version = 'v1';
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'email'
];
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @return string
@ -107,11 +107,7 @@ class Mock extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['id'])) {
return $user['id'];
}
return '';
return $user['id'] ?? '';
}
/**
@ -123,17 +119,13 @@ class Mock extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
* Check if the OAuth email is verified
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -151,11 +143,7 @@ class Mock extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**

View file

@ -9,27 +9,27 @@ class Notion extends OAuth2
/**
* @var string
*/
private $endpoint = 'https://api.notion.com/v1';
private string $endpoint = 'https://api.notion.com/v1';
/**
* @var string
*/
private $version = '2021-08-16';
private string $version = '2021-08-16';
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [];
protected array $scopes = [];
/**
* @return string
@ -103,7 +103,7 @@ class Notion extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -111,15 +111,11 @@ class Notion extends OAuth2
{
$response = $this->getUser($accessToken);
if (isset($response['bot']['owner']['user']['id'])) {
return $response['bot']['owner']['user']['id'];
}
return '';
return $response['bot']['owner']['user']['id'] ?? '';
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -127,11 +123,7 @@ class Notion extends OAuth2
{
$response = $this->getUser($accessToken);
if(isset($response['bot']['owner']['user']['person']['email'])){
return $response['bot']['owner']['user']['person']['email'];
}
return '';
return $response['bot']['owner']['user']['person']['email'] ?? '';
}
/**
@ -139,7 +131,7 @@ class Notion extends OAuth2
*
* If present, the email is verified. This was verfied through a manual Notion sign up process
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -151,7 +143,7 @@ class Notion extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -159,11 +151,7 @@ class Notion extends OAuth2
{
$response = $this->getUser($accessToken);
if (isset($response['bot']['owner']['user']['name'])) {
return $response['bot']['owner']['user']['name'];
}
return '';
return $response['bot']['owner']['user']['name'] ?? '';
}
/**
@ -171,7 +159,7 @@ class Notion extends OAuth2
*
* @return array
*/
protected function getUser(string $accessToken)
protected function getUser(string $accessToken): array
{
$headers = [
'Notion-Version: ' . $this->version,

View file

@ -12,7 +12,7 @@ class Okta extends OAuth2
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'openid',
'profile',
'email',
@ -22,12 +22,12 @@ class Okta extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @return string
@ -115,11 +115,7 @@ class Okta extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['sub'])) {
return $user['sub'];
}
return '';
return $user['sub'] ?? '';
}
/**
@ -131,11 +127,7 @@ class Okta extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -143,7 +135,7 @@ class Okta extends OAuth2
*
* @link https://developer.okta.com/docs/reference/api/oidc/#userinfo
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -151,7 +143,7 @@ class Okta extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email_verified']) && $user['email_verified'] === true) {
if ($user['email_verified'] ?? false) {
return true;
}
@ -167,11 +159,7 @@ class Okta extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**
@ -199,7 +187,7 @@ class Okta extends OAuth2
{
$secret = $this->getAppSecret();
return (isset($secret['clientSecret'])) ? $secret['clientSecret'] : '';
return $secret['clientSecret'] ?? '';
}
/**
@ -210,7 +198,8 @@ class Okta extends OAuth2
protected function getOktaDomain(): string
{
$secret = $this->getAppSecret();
return (isset($secret['oktaDomain'])) ? $secret['oktaDomain'] : '';
return $secret['oktaDomain'] ?? '';
}
/**
@ -221,7 +210,8 @@ class Okta extends OAuth2
protected function getAuthorizationServerId(): string
{
$secret = $this->getAppSecret();
return (isset($secret['authorizationServerId'])) ? $secret['authorizationServerId'] : 'default';
return $secret['authorizationServerId'] ?? 'default';
}
/**

View file

@ -12,7 +12,7 @@ class Paypal extends OAuth2
/**
* @var array
*/
private $endpoint = [
private array $endpoint = [
'sandbox' => 'https://www.sandbox.paypal.com/',
'live' => 'https://www.paypal.com/',
];
@ -20,7 +20,7 @@ class Paypal extends OAuth2
/**
* @var array
*/
private $resourceEndpoint = [
private array $resourceEndpoint = [
'sandbox' => 'https://api.sandbox.paypal.com/v1/',
'live' => 'https://api.paypal.com/v1/',
];
@ -28,22 +28,22 @@ class Paypal extends OAuth2
/**
* @var string
*/
protected $environment = 'live';
protected string $environment = 'live';
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'openid',
'profile',
'email'
@ -131,11 +131,7 @@ class Paypal extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['payer_id'])) {
return $user['payer_id'];
}
return '';
return $user['payer_id'] ?? '';
}
/**
@ -165,7 +161,7 @@ class Paypal extends OAuth2
*
* @link https://developer.paypal.com/docs/api/identity/v1/#userinfo_get
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -173,7 +169,7 @@ class Paypal extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['verified_account']) && $user['verified_account'] === true) {
if ($user['verified_account'] ?? false) {
return true;
}
@ -189,11 +185,7 @@ class Paypal extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**

View file

@ -6,7 +6,7 @@ use Appwrite\Auth\OAuth2\Paypal;
class PaypalSandbox extends Paypal
{
protected $environment = 'sandbox';
protected string $environment = 'sandbox';
/**
* @return string

View file

@ -14,17 +14,17 @@ class Salesforce extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
"openid"
];
@ -37,7 +37,7 @@ class Salesforce extends OAuth2
}
/**
* @param $state
* @param string $state
*
* @return array
*/
@ -125,11 +125,7 @@ class Salesforce extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['user_id'])) {
return $user['user_id'];
}
return '';
return $user['user_id'] ?? '';
}
/**
@ -141,11 +137,7 @@ class Salesforce extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -153,7 +145,7 @@ class Salesforce extends OAuth2
*
* @link https://help.salesforce.com/s/articleView?id=sf.remoteaccess_using_userinfo_endpoint.htm&type=5
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -161,7 +153,7 @@ class Salesforce extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email_verified']) && $user['email_verified'] === true) {
if ($user['email_verified'] ?? false) {
return true;
}
@ -177,11 +169,7 @@ class Salesforce extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**

View file

@ -3,24 +3,23 @@
namespace Appwrite\Auth\OAuth2;
use Appwrite\Auth\OAuth2;
use Utopia\Exception;
class Slack extends OAuth2
{
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'identity.avatar',
'identity.basic',
'identity.email',
@ -105,11 +104,7 @@ class Slack extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['user']['id'])) {
return $user['user']['id'];
}
return '';
return $user['user']['id'] ?? '';
}
/**
@ -121,11 +116,7 @@ class Slack extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['user']['email'])) {
return $user['user']['email'];
}
return '';
return $user['user']['email'] ?? '';
}
/**
@ -135,7 +126,7 @@ class Slack extends OAuth2
*
* @link https://slack.com/help/articles/207262907-Change-your-email-address
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -155,11 +146,7 @@ class Slack extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['user']['name'])) {
return $user['user']['name'];
}
return '';
return $user['user']['name'] ?? '';
}
/**

View file

@ -13,29 +13,29 @@ class Spotify extends OAuth2
/**
* @var string
*/
private $endpoint = 'https://accounts.spotify.com/';
private string $endpoint = 'https://accounts.spotify.com/';
/**
* @var string
*/
private $resourceEndpoint = 'https://api.spotify.com/v1/';
private string $resourceEndpoint = 'https://api.spotify.com/v1/';
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'user-read-email',
];
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @return string
@ -110,7 +110,7 @@ class Spotify extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -118,15 +118,11 @@ class Spotify extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['id'])) {
return $user['id'];
}
return '';
return $user['id'] ?? '';
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -134,11 +130,7 @@ class Spotify extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -148,7 +140,7 @@ class Spotify extends OAuth2
*
* @link https://developer.spotify.com/documentation/web-api/reference/#/operations/get-current-users-profile
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -158,7 +150,7 @@ class Spotify extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -166,11 +158,7 @@ class Spotify extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['display_name'])) {
return $user['display_name'];
}
return '';
return $user['display_name'] ?? '';
}
/**

View file

@ -10,30 +10,29 @@ class Stripe extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var string
*/
protected $stripeAccountId = '';
protected string $stripeAccountId = '';
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'read_write',
];
/**
* @return string
* @var array
*/
protected $grantType = [
protected array $grantType = [
'authorize' => 'authorization_code',
'refresh' => 'refresh_token',
];
@ -110,7 +109,7 @@ class Stripe extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -118,15 +117,11 @@ class Stripe extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['id'])) {
return $user['id'];
}
return '';
return $user['id'] ?? '';
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -146,7 +141,7 @@ class Stripe extends OAuth2
*
* If present, the email is verified. This was verfied through a manual Stripe sign up process
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -158,7 +153,7 @@ class Stripe extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -166,11 +161,7 @@ class Stripe extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**
@ -189,8 +180,6 @@ class Stripe extends OAuth2
),
true
);
}
return $this->user;

View file

@ -12,35 +12,37 @@ class Tradeshift extends OAuth2
const TRADESHIFT_SANDBOX_API_DOMAIN = 'api-sandbox.tradeshift.com';
const TRADESHIFT_API_DOMAIN = 'api.tradeshift.com';
private $apiDomain = [
private array $apiDomain = [
'sandbox' => self::TRADESHIFT_SANDBOX_API_DOMAIN,
'live' => self::TRADESHIFT_API_DOMAIN,
];
private $endpoint = [
private array $endpoint = [
'sandbox' => 'https://' . self::TRADESHIFT_SANDBOX_API_DOMAIN . '/tradeshift/',
'live' => 'https://' . self::TRADESHIFT_API_DOMAIN . '/tradeshift/',
];
private $resourceEndpoint = [
private array $resourceEndpoint = [
'sandbox' => 'https://' . self::TRADESHIFT_SANDBOX_API_DOMAIN . '/tradeshift/rest/external/',
'live' => 'https://' . self::TRADESHIFT_API_DOMAIN . '/tradeshift/rest/external/',
];
protected $environment = 'live';
protected string $environment = 'live';
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
protected $scopes = [
/**
* @var array
*/
protected array$scopes = [
'openid',
'offline',
];
@ -146,7 +148,7 @@ class Tradeshift extends OAuth2
*
* If present, the email is verified. This was verfied through a manual Tradeshift sign up process
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/

View file

@ -6,7 +6,7 @@ use Appwrite\Auth\OAuth2\Tradeshift;
class TradeshiftBox extends Tradeshift
{
protected $environment = 'sandbox';
protected string $environment = 'sandbox';
/**
* @return string

View file

@ -13,29 +13,29 @@ class Twitch extends OAuth2
/**
* @var string
*/
private $endpoint = 'https://id.twitch.tv/oauth2/';
private string $endpoint = 'https://id.twitch.tv/oauth2/';
/**
* @var string
*/
private $resourceEndpoint = 'https://api.twitch.tv/helix/users';
private string $resourceEndpoint = 'https://api.twitch.tv/helix/users';
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'user:read:email',
];
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @return string
@ -109,7 +109,7 @@ class Twitch extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -117,15 +117,11 @@ class Twitch extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['id'])) {
return $user['id'];
}
return '';
return $user['id'] ?? '';
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -133,11 +129,7 @@ class Twitch extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -147,7 +139,7 @@ class Twitch extends OAuth2
*
* @link https://dev.twitch.tv/docs/api/reference#get-users
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -159,7 +151,7 @@ class Twitch extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -167,11 +159,7 @@ class Twitch extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['display_name'])) {
return $user['display_name'];
}
return '';
return $user['display_name'] ?? '';
}
/**

View file

@ -12,17 +12,17 @@ class WordPress extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'auth',
];
@ -100,7 +100,7 @@ class WordPress extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -108,15 +108,11 @@ class WordPress extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['ID'])) {
return $user['ID'];
}
return '';
return $user['ID'] ?? '';
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -124,8 +120,8 @@ class WordPress extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email']) && $user['verified']) {
return $user['email'];
if ($user['verified']) {
return $user['email'] ?? '';
}
return '';
@ -136,7 +132,7 @@ class WordPress extends OAuth2
*
* @link https://developer.wordpress.com/docs/api/1.1/get/me/
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -144,7 +140,7 @@ class WordPress extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email_verified']) && $user['email_verified'] === true) {
if ($user['email_verified'] ?? false) {
return true;
}
@ -152,7 +148,7 @@ class WordPress extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -160,11 +156,7 @@ class WordPress extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['username'])) {
return $user['username'];
}
return '';
return $user['username'] ?? '';
}
/**

View file

@ -13,17 +13,17 @@ class Yahoo extends OAuth2
/**
* @var string
*/
private $endpoint = 'https://api.login.yahoo.com/oauth2/';
private string $endpoint = 'https://api.login.yahoo.com/oauth2/';
/**
* @var string
*/
private $resourceEndpoint = 'https://api.login.yahoo.com/openid/v1/userinfo';
private string $resourceEndpoint = 'https://api.login.yahoo.com/openid/v1/userinfo';
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'sdct-r',
'sdpp-w',
];
@ -31,12 +31,12 @@ class Yahoo extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @return string
@ -130,7 +130,7 @@ class Yahoo extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -138,15 +138,11 @@ class Yahoo extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['sub'])) {
return $user['sub'];
}
return '';
return $user['sub'] ?? '';
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -154,11 +150,7 @@ class Yahoo extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -166,7 +158,7 @@ class Yahoo extends OAuth2
*
* If present, the email is verified. This was verfied through a manual Yahoo sign up process
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -178,7 +170,7 @@ class Yahoo extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
@ -186,11 +178,7 @@ class Yahoo extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['name'])) {
return $user['name'];
}
return '';
return $user['name'] ?? '';
}
/**

View file

@ -12,17 +12,17 @@ class Yammer extends OAuth2
/**
* @var string
*/
private $endpoint = 'https://www.yammer.com/oauth2/';
private string $endpoint = 'https://www.yammer.com/oauth2/';
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @return string
@ -107,11 +107,7 @@ class Yammer extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['id'])) {
return $user['id'];
}
return '';
return $user['id'] ?? '';
}
/**
@ -123,11 +119,7 @@ class Yammer extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['email'])) {
return $user['email'];
}
return '';
return $user['email'] ?? '';
}
/**
@ -135,7 +127,7 @@ class Yammer extends OAuth2
*
* If present, the email is verified. This was verfied through a manual Yammer sign up process
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -155,11 +147,7 @@ class Yammer extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['full_name'])) {
return $user['full_name'];
}
return '';
return $user['full_name'] ?? '';
}
/**

View file

@ -14,17 +14,17 @@ class Yandex extends OAuth2
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [];
protected array $scopes = [];
/**
* @return string
@ -35,7 +35,7 @@ class Yandex extends OAuth2
}
/**
* @param $state
* @param string $state
*
* @return array
*/
@ -121,11 +121,7 @@ class Yandex extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['id'])) {
return $user['id'];
}
return '';
return $user['id'] ?? '';
}
/**
@ -137,17 +133,13 @@ class Yandex extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['default_email'])) {
return $user['default_email'];
}
return '';
return $user['default_email'] ?? '';
}
/**
* Check if the OAuth email is verified
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -165,11 +157,7 @@ class Yandex extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['display_name'])) {
return $user['display_name'];
}
return '';
return $user['display_name'] ?? '';
}
/**

View file

@ -9,27 +9,27 @@ class Zoom extends OAuth2
/**
* @var string
*/
private $endpoint = 'https://zoom.us';
private string $endpoint = 'https://zoom.us';
/**
* @var string
*/
private $version = '2022-03-26';
private string $version = '2022-03-26';
/**
* @var array
*/
protected $user = [];
protected array $user = [];
/**
* @var array
*/
protected $tokens = [];
protected array $tokens = [];
/**
* @var array
*/
protected $scopes = [
protected array $scopes = [
'user_profile'
];
@ -105,24 +105,26 @@ class Zoom extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
public function getUserID(string $accessToken): string
{
$response = $this->getUser($accessToken);
return $response['id'] ?? '';
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
public function getUserEmail(string $accessToken): string
{
$response = $this->getUser($accessToken);
return $response['email'] ?? '';
}
@ -131,7 +133,7 @@ class Zoom extends OAuth2
*
* @link https://marketplace.zoom.us/docs/api-reference/zoom-api/methods/#operation/user
*
* @param $accessToken
* @param string $accessToken
*
* @return bool
*/
@ -139,7 +141,7 @@ class Zoom extends OAuth2
{
$user = $this->getUser($accessToken);
if (isset($user['verified']) && $user['verified'] === 1) {
if (($user['verified'] ?? false) === 1) {
return true;
}
@ -147,13 +149,14 @@ class Zoom extends OAuth2
}
/**
* @param $accessToken
* @param string $accessToken
*
* @return string
*/
public function getUserName(string $accessToken): string
{
$response = $this->getUser($accessToken);
return ($response['first_name'] ?? '') . ' ' . ($response['last_name'] ?? '');
}