mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-11-15 09:47:46 +05:30
Updated implicit grant
This commit is contained in:
parent
b9570ac6b0
commit
2866185349
@ -77,40 +77,31 @@ class Implict implements GrantTypeInterface {
|
|||||||
*/
|
*/
|
||||||
public function completeFlow($authParams = null)
|
public function completeFlow($authParams = null)
|
||||||
{
|
{
|
||||||
// Remove any old sessions the user might have
|
// Remove any old sessions the user might have
|
||||||
$this->authServer->getStorage('session')->deleteSession($authParams['client_id'], 'user', $authParams['user_id']);
|
$this->authServer->getStorage('session')->deleteSession($authParams['client_id'], 'user', $authParams['user_id']);
|
||||||
|
|
||||||
// Generate a new access token
|
// Generate a new access token
|
||||||
$accessToken = SecureKey::make();
|
$accessToken = SecureKey::make();
|
||||||
|
|
||||||
// Compute expiry time
|
// Compute expiry time
|
||||||
$accessTokenExpires = time() + $this->authServer->getExpiresIn();
|
$accessTokenExpires = time() + $this->authServer->getExpiresIn();
|
||||||
|
|
||||||
// Create a new session
|
// Create a new session
|
||||||
$sessionId = $this->authServer->getStorage('session')->createSession(
|
$sessionId = $this->authServer->getStorage('session')->createSession($authParams['client_id'], 'user', $authParams['user_id']);
|
||||||
$authParams['client_id'],
|
|
||||||
$authParams['redirect_uri'],
|
|
||||||
'user',
|
|
||||||
$authParams['user_id'],
|
|
||||||
null,
|
|
||||||
$accessToken,
|
|
||||||
null,
|
|
||||||
$accessTokenExpires,
|
|
||||||
'granted'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Associate scopes with the new session
|
// Create an access token
|
||||||
foreach ($authParams['scopes'] as $scope)
|
$accessTokenId = $this->authServer->getStorage('session')->associateAccessToken($sessionId, $accessToken, $accessTokenExpires);
|
||||||
{
|
|
||||||
$this->authServer->getStorage('session')->associateScope($sessionId, $scope['id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$response = array(
|
// Associate scopes with the access token
|
||||||
'access_token' => $accessToken
|
foreach ($authParams['scopes'] as $scope) {
|
||||||
);
|
$this->authServer->getStorage('session')->associateScope($accessTokenId, $scope['id']);
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$response = array(
|
||||||
|
'access_token' => $accessToken
|
||||||
|
);
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user