From 514aabb8389a55df524044a44d5238ad7f0134cc Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Tue, 29 Jan 2013 16:23:41 +0000 Subject: [PATCH] Updated newAuthoriseRequest method --- src/OAuth2/AuthServer.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/OAuth2/AuthServer.php b/src/OAuth2/AuthServer.php index 2ff9df46..c83ad822 100644 --- a/src/OAuth2/AuthServer.php +++ b/src/OAuth2/AuthServer.php @@ -2,6 +2,7 @@ namespace OAuth2; +use OAuth2\Util; use OAuth2\Storage\SessionInterface; use OAuth2\Storage\ClientInterface; use OAuth2\Storage\ScopeInterface; @@ -227,7 +228,22 @@ class AuthServer */ public function newAuthoriseRequest($type, $typeId, $authoriseParams) { + // Generate an auth code + $authCode = SecureKey::make(); + // Remove any old sessions the user might have + $this->getStorage('session')->delete($authoriseParams['client_id'], $type, $typeId); + + // Create a new session + $sessionId = $this->getStorage('session')->create($authoriseParams['client_id'], $authoriseParams['redirect_uri'], $type, $typeId, $authCode); + + // Associate scopes with the new session + foreach ($authoriseParams['scopes'] as $scope) + { + $this->getStorage('session')->associateScope($sessionId, $scope['id']); + } + + return $authCode; } /**