mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-30 02:33:14 +05:30
Added newAuthoriseRequest function
This commit is contained in:
parent
927d1dc838
commit
5fbdccde40
@ -173,6 +173,47 @@ class Server
|
||||
return $params;
|
||||
}
|
||||
|
||||
function newAuthoriseRequest(string $typeId, array $authoriseParams)
|
||||
{
|
||||
// Check if the user already has an access token
|
||||
$accessToken = $this->db->hasAccessToken($userId,
|
||||
$authoriseParams['client_id']);
|
||||
|
||||
if ($accessToken !== false) {
|
||||
|
||||
// Validate the access token matches the scopes requested
|
||||
$originalScopes = $this->db->accessTokenScopes($accessToken);
|
||||
|
||||
foreach ($authoriseParams['scopes'] as $scope) {
|
||||
|
||||
if ( ! in_array($scope, $originalScopes))
|
||||
{
|
||||
throw new OAuthServerClientException('invalid_scope: ' .
|
||||
$this->errors['invalid_scope']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// The user has authorised the client so generate a new
|
||||
// authorisation code and return it
|
||||
|
||||
$authCode = $this->newAuthCode($authoriseParams['client_id'],
|
||||
'user', $typeId, $authoriseParams['redirect_uri'],
|
||||
$authoriseParams['scopes'], $accessToken);
|
||||
|
||||
return $authCode;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$authCode = $this->newAuthCode($authoriseParams['client_id'],
|
||||
'user', $typeId, $authoriseParams['redirect_uri'],
|
||||
$authoriseParams['scopes']);
|
||||
|
||||
return $authCode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique code
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user