From 60c453ef379a0eb7bb1198ff78032a9ee6adb353 Mon Sep 17 00:00:00 2001 From: Sonia Zorba <sonia.zorba@inaf.it> Date: Wed, 10 Mar 2021 18:18:25 +0100 Subject: [PATCH] Parsed GMS join response --- classes/login/GmsClient.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/classes/login/GmsClient.php b/classes/login/GmsClient.php index 7efacb1..0c3c4e8 100644 --- a/classes/login/GmsClient.php +++ b/classes/login/GmsClient.php @@ -36,7 +36,13 @@ class GmsClient { $info = curl_getinfo($conn); if ($info['http_code'] === 200) { + error_log($response); + $joinResult = json_decode($response); curl_close($conn); + if (!array_key_exists('mergedId', $joinResult)) { + throw new ServerErrorException('GMS join response has an invalid payload'); + } + return $joinResult->mergedId; } else { //show information regarding the error curl_close($conn); @@ -47,9 +53,6 @@ class GmsClient { } throw new ServerErrorException('Error: GMS response code: ' . $httpCode); } - - // TODO: return id extracted from GMS response - return $userId1; } private function getJoinAccessToken(int $userId1, int $userId2): string { -- GitLab