| @@ 57-72 (lines=16) @@ | ||
| 54 | * |
|
| 55 | * @return \League\OAuth2\Server\Entity\SessionEntity |
|
| 56 | */ |
|
| 57 | public function getByAccessToken(AccessTokenEntity $accessToken) |
|
| 58 | { |
|
| 59 | $result = $this->getConnection()->table('oauth_sessions') |
|
| 60 | ->select('oauth_sessions.*') |
|
| 61 | ->join('oauth_access_tokens', 'oauth_sessions.id', '=', 'oauth_access_tokens.session_id') |
|
| 62 | ->where('oauth_access_tokens.id', $accessToken->getId()) |
|
| 63 | ->first(); |
|
| 64 | ||
| 65 | if (is_null($result)) { |
|
| 66 | return; |
|
| 67 | } |
|
| 68 | ||
| 69 | return (new SessionEntity($this->getServer())) |
|
| 70 | ->setId($result->id) |
|
| 71 | ->setOwner($result->owner_type, $result->owner_id); |
|
| 72 | } |
|
| 73 | ||
| 74 | /** |
|
| 75 | * Get a session's scopes. |
|
| @@ 149-164 (lines=16) @@ | ||
| 146 | * |
|
| 147 | * @return \League\OAuth2\Server\Entity\SessionEntity |
|
| 148 | */ |
|
| 149 | public function getByAuthCode(AuthCodeEntity $authCode) |
|
| 150 | { |
|
| 151 | $result = $this->getConnection()->table('oauth_sessions') |
|
| 152 | ->select('oauth_sessions.*') |
|
| 153 | ->join('oauth_auth_codes', 'oauth_sessions.id', '=', 'oauth_auth_codes.session_id') |
|
| 154 | ->where('oauth_auth_codes.id', $authCode->getId()) |
|
| 155 | ->first(); |
|
| 156 | ||
| 157 | if (is_null($result)) { |
|
| 158 | return; |
|
| 159 | } |
|
| 160 | ||
| 161 | return (new SessionEntity($this->getServer())) |
|
| 162 | ->setId($result->id) |
|
| 163 | ->setOwner($result->owner_type, $result->owner_id); |
|
| 164 | } |
|
| 165 | } |
|
| 166 | ||