Skip to content

Commit

Permalink
Response validate.
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Oct 10, 2022
1 parent ab63676 commit f0f05d3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Providers/Coding.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Overtrue\Socialite\Contracts;
use Overtrue\Socialite\Exceptions\InvalidArgumentException;
use Overtrue\Socialite\User;
use Overtrue\Socialite\Exceptions;

class Coding extends Base
{
Expand Down Expand Up @@ -66,10 +67,11 @@ protected function getTokenFields(string $code): array

/**
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws \Overtrue\Socialite\Exceptions\BadRequestException
*/
protected function getUserByToken(string $token): array
{
$response = $this->getHttpClient()->get(
$responseInstance = $this->getHttpClient()->get(
"$this->teamUrl/api/me",
[
'query' => [
Expand All @@ -78,7 +80,13 @@ protected function getUserByToken(string $token): array
]
);

return $this->fromJsonBody($response);
$response = $this->fromJsonBody($responseInstance);

if (empty($response[Contracts\ABNF_ID])) {
throw new Exceptions\BadRequestException((string) $responseInstance->getBody());
}

return $response;
}

#[Pure]
Expand Down

0 comments on commit f0f05d3

Please sign in to comment.