Updated completeFlow

This commit is contained in:
Alex Bilbie 2013-04-29 11:31:07 +01:00
parent 2dcb81d93c
commit 13c67c9a40

View File

@ -222,18 +222,14 @@ class AuthCode implements GrantTypeInterface {
// A session ID was returned so update it with an access token and remove the authorisation code // A session ID was returned so update it with an access token and remove the authorisation code
$accessToken = SecureKey::make(); $accessToken = SecureKey::make();
$refreshToken = ($this->authServer->hasGrantType('refresh_token')) ? SecureKey::make() : null;
$accessTokenExpires = time() + $this->authServer->getExpiresIn(); $accessTokenExpires = time() + $this->authServer->getExpiresIn();
$accessTokenExpiresIn = $this->authServer->getExpiresIn(); $accessTokenExpiresIn = $this->authServer->getExpiresIn();
$this->authServer->getStorage('session')->deleteAuthCode($session['id']); // Remove the auth code
$this->authServer->getStorage('session')->removeAuthCode($session['id']);
$accessTokenId = $this->authServer->getStorage('session')->updateSession($session['id'], array( // Create an access token
'access_token' => $accessToken, $accessTokenId = $this->authServer->getStorage('session')->associateAccessToken($session['id'], $accessToken, $accessTokenExpires));
'access_token_expire' => $accessTokenExpires,
'refresh_token' => $refreshToken
));
// Associate scopes with the access token // Associate scopes with the access token
if ( ! is_null($session['scope_ids'])) { if ( ! is_null($session['scope_ids'])) {
@ -251,7 +247,10 @@ class AuthCode implements GrantTypeInterface {
'expires_in' => $accessTokenExpiresIn 'expires_in' => $accessTokenExpiresIn
); );
// Associate a refresh token if set
if ($this->authServer->hasGrantType('refresh_token')) { if ($this->authServer->hasGrantType('refresh_token')) {
$refreshToken = SecureKey::make();
$this->authServer->getStorage('session')->associateRefreshToken($accessTokenId, $refreshToken);
$response['refresh_token'] = $refreshToken; $response['refresh_token'] = $refreshToken;
} }