From b77ebc1ba5b01b87209cdd0411601ec2a6d56da0 Mon Sep 17 00:00:00 2001 From: Luca Degasperi Date: Wed, 11 Dec 2013 10:32:36 +0100 Subject: [PATCH] Fix for #33 and other fluent query quirks --- .gitignore | 3 ++- .../OAuth2Server/Repositories/FluentClient.php | 14 ++++++++++++++ .../OAuth2Server/Repositories/FluentSession.php | 3 ++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2c1fc0c1..16d544e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /vendor composer.phar composer.lock -.DS_Store \ No newline at end of file +.DS_Store +oauth2-server-laravel.* \ No newline at end of file diff --git a/src/LucaDegasperi/OAuth2Server/Repositories/FluentClient.php b/src/LucaDegasperi/OAuth2Server/Repositories/FluentClient.php index 8601bbe6..92c7983a 100644 --- a/src/LucaDegasperi/OAuth2Server/Repositories/FluentClient.php +++ b/src/LucaDegasperi/OAuth2Server/Repositories/FluentClient.php @@ -13,15 +13,29 @@ public function getClient($clientId, $clientSecret = null, $redirectUri = null, if (! is_null($redirectUri) && is_null($clientSecret)) { $query = DB::table('oauth_clients') + ->select( + 'oauth_clients.id as id', + 'oauth_clients.secret as secret', + 'oauth_client_endpoints.redirect_uri as redirect_uri', + 'oauth_clients.name as name') ->join('oauth_client_endpoints', 'oauth_clients.id', '=', 'oauth_client_endpoints.client_id') ->where('oauth_clients.id', $clientId) ->where('oauth_client_endpoints.redirect_uri', $redirectUri); } elseif (! is_null($clientSecret) && is_null($redirectUri)) { $query = DB::table('oauth_clients') + ->select( + 'oauth_clients.id as id', + 'oauth_clients.secret as secret', + 'oauth_clients.name as name') ->where('oauth_clients.id', $clientId) ->where('oauth_clients.secret', $clientSecret); } elseif (! is_null($clientSecret) && ! is_null($redirectUri)) { $query = DB::table('oauth_clients') + ->select( + 'oauth_clients.id as id', + 'oauth_clients.secret as secret', + 'oauth_client_endpoints.redirect_uri as redirect_uri', + 'oauth_clients.name as name') ->join('oauth_client_endpoints', 'oauth_clients.id', '=', 'oauth_client_endpoints.client_id') ->where('oauth_clients.id', $clientId) ->where('oauth_clients.secret', $clientSecret) diff --git a/src/LucaDegasperi/OAuth2Server/Repositories/FluentSession.php b/src/LucaDegasperi/OAuth2Server/Repositories/FluentSession.php index cbb7e5f2..94918ab2 100644 --- a/src/LucaDegasperi/OAuth2Server/Repositories/FluentSession.php +++ b/src/LucaDegasperi/OAuth2Server/Repositories/FluentSession.php @@ -98,6 +98,7 @@ public function validateAuthCode($clientId, $redirectUri, $authCode) public function validateAccessToken($accessToken) { $result = DB::table('oauth_session_access_tokens') + ->select('oauth_sessions.*') ->join('oauth_sessions', 'oauth_session_access_tokens.session_id', '=', 'oauth_sessions.id') ->where('access_token', $accessToken) ->where('access_token_expires', '>=', time()) @@ -195,7 +196,7 @@ public function deleteExpired() { $time = time(); $expiredSessions = DB::table('oauth_sessions') - ->select(array('oauth_sessions.id as session_id')) + ->select('oauth_sessions.id as session_id') ->join('oauth_session_access_tokens', 'oauth_session_access_tokens.session_id', '=', 'oauth_sessions.id') ->leftJoin('oauth_session_refresh_tokens', 'oauth_session_refresh_tokens.session_access_token_id', '=', 'oauth_session_access_tokens.id') ->where('oauth_session_access_tokens.access_token_expires', '<', $time)