1
0
Fork 0
mirror of synced 2024-06-26 18:20:43 +12:00

feat: add method to check for email verification

This commit is contained in:
Christy Jacob 2022-04-27 22:08:32 +03:00
parent c145723b22
commit feb124d165
29 changed files with 299 additions and 19 deletions

View file

@ -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);

View file

@ -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
*

View file

@ -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
*

View file

@ -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
*

View file

@ -148,6 +148,16 @@ class Bitly extends OAuth2
return '';
}
/**
* Is the OAuth email verified?
*
* @return bool
*/
public function isEmailVerififed(): bool
{
return false;
}
/**
* @param $accessToken
*

View file

@ -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
*

View file

@ -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
*

View file

@ -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
*

View file

@ -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
*

View file

@ -137,6 +137,16 @@ class Github extends OAuth2
return '';
}
/**
* Is the OAuth email verified?
*
* @return bool
*/
public function isEmailVerififed(): bool
{
return false;
}
/**
* @param $accessToken
*

View file

@ -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
*

View file

@ -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
*

View file

@ -148,6 +148,16 @@ class Linkedin extends OAuth2
return '';
}
/**
* Is the OAuth email verified?
*
* @return bool
*/
public function isEmailVerififed(): bool
{
return false;
}
/**
* @param $accessToken
*

View file

@ -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
*

View file

@ -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
*

View file

@ -134,6 +134,16 @@ class Notion extends OAuth2
return '';
}
/**
* Is the OAuth email verified?
*
* @return bool
*/
public function isEmailVerififed(): bool
{
return false;
}
/**
* @param $accessToken
*

View file

@ -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
*

View file

@ -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
*

View file

@ -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
*

View file

@ -141,6 +141,16 @@ class Spotify extends OAuth2
return '';
}
/**
* Is the OAuth email verified?
*
* @return bool
*/
public function isEmailVerififed(): bool
{
return false;
}
/**
* @param $accessToken
*

View file

@ -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
*

View file

@ -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
*

View file

@ -140,6 +140,16 @@ class Twitch extends OAuth2
return '';
}
/**
* Is the OAuth email verified?
*
* @return bool
*/
public function isEmailVerififed(): bool
{
return false;
}
/**
* @param $accessToken
*

View file

@ -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
*

View file

@ -131,6 +131,16 @@ class WordPress extends OAuth2
return '';
}
/**
* Is the OAuth email verified?
*
* @return bool
*/
public function isEmailVerififed(): bool
{
return false;
}
/**
* @param $accessToken
*

View file

@ -161,6 +161,16 @@ class Yahoo extends OAuth2
return '';
}
/**
* Is the OAuth email verified?
*
* @return bool
*/
public function isEmailVerififed(): bool
{
return false;
}
/**
* @param $accessToken
*

View file

@ -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
*

View file

@ -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
*

View file

@ -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
*