diff --git a/src/Providers/WeWork.php b/src/Providers/WeWork.php index 0b26df2..c36e85b 100644 --- a/src/Providers/WeWork.php +++ b/src/Providers/WeWork.php @@ -141,8 +141,10 @@ protected function getUserId(string $token, string $code): array $response = \json_decode($response->getBody(), true) ?? []; - if (($response['errcode'] ?? 1) > 0 || empty($response['UserId'])) { + if (($response['errcode'] ?? 1) > 0 || (empty($response['UserId']) && empty($response['OpenId']))) { throw new AuthorizeFailedException('Failed to get user openid:' . $response['errmsg'] ?? 'Unknown.', $response); + } else if (empty($response['UserId'])) { + $this->detailed = false; } return $response; @@ -173,7 +175,7 @@ protected function getUserById(string $userId): array throw new AuthorizeFailedException('Failed to get user:' . $response['errmsg'] ?? 'Unknown.', $response); } - return \json_decode($response->getBody(), true) ?? []; + return $response; } /**