mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-15 17:56:14 +05:30
Reworked newAuthoriseRequest method so that is always creates a new session (and removes any existing sessions)
This commit is contained in:
parent
17ce8b97d8
commit
411cab1734
@ -201,43 +201,23 @@ maintenance of the server.'
|
|||||||
*/
|
*/
|
||||||
public function newAuthoriseRequest($type, $typeId, $authoriseParams)
|
public function newAuthoriseRequest($type, $typeId, $authoriseParams)
|
||||||
{
|
{
|
||||||
// Check if the user already has an access token
|
// Remove any old sessions the user might have
|
||||||
$accessToken = $this->db->hasAccessToken($type, $typeId,
|
$this->db->deleteSession(
|
||||||
$authoriseParams['client_id']);
|
$authoriseParams['client_id'],
|
||||||
|
$type,
|
||||||
|
$typeId
|
||||||
|
);
|
||||||
|
|
||||||
if ($accessToken !== false) {
|
// Create the new auth code
|
||||||
|
$authCode = $this->newAuthCode(
|
||||||
// Validate the access token matches the scopes requested
|
$authoriseParams['client_id'],
|
||||||
$originalScopes = $this->db->accessTokenScopes($accessToken);
|
'user',
|
||||||
|
$typeId,
|
||||||
foreach ($authoriseParams['scopes'] as $scope) {
|
$authoriseParams['redirect_uri'],
|
||||||
|
$authoriseParams['scopes']
|
||||||
if ( ! in_array($scope, $originalScopes)) {
|
);
|
||||||
|
|
||||||
throw new OAuthServerClientException(
|
|
||||||
$this->errors['invalid_scope'], 4);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
return $authCode;
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
$authCode = $this->newAuthCode($authoriseParams['client_id'],
|
|
||||||
'user', $typeId, $authoriseParams['redirect_uri'],
|
|
||||||
$authoriseParams['scopes']);
|
|
||||||
|
|
||||||
return $authCode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user