Skip to content

Commit

Permalink
Fix for #33 and other fluent query quirks
Browse files Browse the repository at this point in the history
  • Loading branch information
lucadegasperi committed Dec 11, 2013
1 parent 1723839 commit b77ebc1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor
composer.phar
composer.lock
.DS_Store
.DS_Store
oauth2-server-laravel.*
14 changes: 14 additions & 0 deletions src/LucaDegasperi/OAuth2Server/Repositories/FluentClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b77ebc1

Please sign in to comment.