Code review changes
This commit is contained in:
parent
aa4d397758
commit
3fe98a6f30
2 changed files with 8 additions and 3 deletions
|
@ -1714,6 +1714,11 @@ App::patch('/v1/account/sessions/:sessionId')
|
||||||
$appSecret = $project->getAttribute('providers', [])[$provider.'Secret'] ?? '{}';
|
$appSecret = $project->getAttribute('providers', [])[$provider.'Secret'] ?? '{}';
|
||||||
|
|
||||||
$className = 'Appwrite\\Auth\\OAuth2\\'.\ucfirst($provider);
|
$className = 'Appwrite\\Auth\\OAuth2\\'.\ucfirst($provider);
|
||||||
|
|
||||||
|
if (!\class_exists($className)) {
|
||||||
|
throw new Exception('Provider is not supported', 501);
|
||||||
|
}
|
||||||
|
|
||||||
$oauth2 = new $className($appId, $appSecret, '', [], []);
|
$oauth2 = new $className($appId, $appSecret, '', [], []);
|
||||||
|
|
||||||
$oauth2->refreshTokens($refreshToken);
|
$oauth2->refreshTokens($refreshToken);
|
||||||
|
|
|
@ -124,7 +124,7 @@ abstract class OAuth2
|
||||||
public function getAccessToken(string $code):string
|
public function getAccessToken(string $code):string
|
||||||
{
|
{
|
||||||
$tokens = $this->getTokens($code);
|
$tokens = $this->getTokens($code);
|
||||||
return $tokens['access_token'];
|
return $tokens['access_token'] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,7 +135,7 @@ abstract class OAuth2
|
||||||
public function getRefreshToken(string $code):string
|
public function getRefreshToken(string $code):string
|
||||||
{
|
{
|
||||||
$tokens = $this->getTokens($code);
|
$tokens = $this->getTokens($code);
|
||||||
return $tokens['refresh_token'];
|
return $tokens['refresh_token'] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -146,7 +146,7 @@ abstract class OAuth2
|
||||||
public function getAccessTokenExpiry(string $code):string
|
public function getAccessTokenExpiry(string $code):string
|
||||||
{
|
{
|
||||||
$tokens = $this->getTokens($code);
|
$tokens = $this->getTokens($code);
|
||||||
return $tokens['expires_in'];
|
return $tokens['expires_in'] ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// The parseState function was designed specifically for Amazon OAuth2 Adapter to override.
|
// The parseState function was designed specifically for Amazon OAuth2 Adapter to override.
|
||||||
|
|
Loading…
Reference in a new issue