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

feat: added check for Google OAuth

This commit is contained in:
Christy Jacob 2022-05-05 20:07:27 +04:00
parent 974a684032
commit e2db8faaf3

View file

@ -140,12 +140,20 @@ class Google extends OAuth2
/**
* Check if the OAuth email is verified
*
* @link https://www.oauth.com/oauth2-servers/signing-in-with-google/verifying-the-user-info/
*
* @param $accessToken
*
* @return bool
*/
public function isEmailVerified(string $accessToken): bool
{
$user = $this->getUser($accessToken);
if (isset($user['email_verified']) && $user['email_verified'] === true) {
return true;
}
return false;
}
@ -173,7 +181,7 @@ class Google extends OAuth2
protected function getUser(string $accessToken): array
{
if (empty($this->user)) {
$user = $this->request('GET', 'https://www.googleapis.com/oauth2/v2/userinfo?access_token='.\urlencode($accessToken));
$user = $this->request('GET', 'https://www.googleapis.com/oauth2/v3/userinfo?access_token='.\urlencode($accessToken));
$this->user = \json_decode($user, true);
}