select(['oauth_sessions.id', 'oauth_sessions.owner_type', 'oauth_sessions.owner_id', 'oauth_sessions.client_id', 'oauth_sessions.client_redirect_uri']) ->join('oauth_access_tokens', 'oauth_access_tokens.session_id', '=', 'oauth_sessions.id') ->where('oauth_access_tokens.access_token', $accessToken->getToken()) ->get(); if (count($result) === 1) { // die(var_dump($result)); $session = new SessionEntity($this->server); $session->setId($result[0]['id']); $session->setOwner($result[0]['owner_type'], $result[0]['owner_id']); return $session; } return null; } /** * {@inheritdoc} */ public function getByAuthCode(AuthCodeEntity $authCode) { die(var_dump(__METHOD__, func_get_args())); } /** * {@inheritdoc} */ public function getScopes(SessionEntity $session) { $result = Capsule::table('oauth_sessions') ->select('oauth_scopes.*') ->join('oauth_session_scopes', 'oauth_sessions.id', '=', 'oauth_session_scopes.session_id') ->join('oauth_scopes', 'oauth_scopes.id', '=', 'oauth_session_scopes.scope') ->where('oauth_sessions.id', $session->getId()) ->get(); $scopes = []; foreach ($result as $scope) { $scopes[] = (new ScopeEntity($this->server)) ->setId($scope['id']) ->setDescription($scope['description']); } return $scopes; } /** * {@inheritdoc} */ public function create($ownerType, $ownerId, $clientId, $clientRedirectUri = null) { $id = Capsule::table('oauth_sessions') ->insert([ 'owner_type' => $ownerType, 'owner_id' => $ownerId, 'client_id' => $clientId ]); return $id; } /** * {@inheritdoc} */ public function associateScope(SessionEntity $session, ScopeEntity $scope) { die(var_dump(__CLASS__.'::'.__METHOD__, func_get_args())); } }