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