From 13c67c9a40a9faf470ff24100a127df5c7c868c2 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 29 Apr 2013 11:31:07 +0100 Subject: [PATCH] Updated completeFlow --- src/OAuth2/Grant/AuthCode.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/OAuth2/Grant/AuthCode.php b/src/OAuth2/Grant/AuthCode.php index 2da7701b..ba3b47a6 100644 --- a/src/OAuth2/Grant/AuthCode.php +++ b/src/OAuth2/Grant/AuthCode.php @@ -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 $accessToken = SecureKey::make(); - $refreshToken = ($this->authServer->hasGrantType('refresh_token')) ? SecureKey::make() : null; - $accessTokenExpires = time() + $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( - 'access_token' => $accessToken, - 'access_token_expire' => $accessTokenExpires, - 'refresh_token' => $refreshToken - )); + // Create an access token + $accessTokenId = $this->authServer->getStorage('session')->associateAccessToken($session['id'], $accessToken, $accessTokenExpires)); // Associate scopes with the access token if ( ! is_null($session['scope_ids'])) { @@ -251,7 +247,10 @@ class AuthCode implements GrantTypeInterface { 'expires_in' => $accessTokenExpiresIn ); + // Associate a refresh token if set if ($this->authServer->hasGrantType('refresh_token')) { + $refreshToken = SecureKey::make(); + $this->authServer->getStorage('session')->associateRefreshToken($accessTokenId, $refreshToken); $response['refresh_token'] = $refreshToken; }