Added newAuthoriseRequest function

This commit is contained in:
Alex Bilbie 2012-07-06 19:22:10 +01:00
parent 927d1dc838
commit 5fbdccde40

View File

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