Skip to content

Commit

Permalink
修复 Wework::getUserById 方法重复json_decode问题 (#204)
Browse files Browse the repository at this point in the history
* 修复 Wework::getUserById 方法重复json_decode问题

* 兼容 WeWork 非企业成员授权
  • Loading branch information
her-cat authored Nov 27, 2020
1 parent a57a825 commit ed6bb2d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Providers/WeWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit ed6bb2d

Please sign in to comment.