From 5eaced933dfd779269582c34c4b9510c43c30629 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Mon, 8 Mar 2021 14:58:16 -0500 Subject: [PATCH 1/3] Use uppercase countryCode as index for $countries assoc array --- app/controllers/api/account.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index e8ae76312b..cab25eb746 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -236,9 +236,11 @@ App::post('/v1/account/sessions') ->setStatusCode(Response::STATUS_CODE_CREATED) ; + $countries = $locale->getText('countries'); + $session ->setAttribute('current', true) - ->setAttribute('countryName', (isset($countries[$session->getAttribute('countryCode')])) ? $countries[$session->getAttribute('countryCode')] : $locale->getText('locale.country.unknown')) + ->setAttribute('countryName', (isset($countries[strtoupper($session->getAttribute('countryCode'))])) ? $countries[strtoupper($session->getAttribute('countryCode'))] : $locale->getText('locale.country.unknown')) ; $response->dynamic($session, Response::MODEL_SESSION); @@ -679,8 +681,8 @@ App::get('/v1/account/sessions') continue; } - $token->setAttribute('countryName', (isset($countries[$token->getAttribute('contryCode')])) - ? $countries[$token->getAttribute('contryCode')] + $token->setAttribute('countryName', (isset($countries[strtoupper($token->getAttribute('countryCode'))])) + ? $countries[strtoupper($token->getAttribute('countryCode'))] : $locale->getText('locale.country.unknown')); $token->setAttribute('current', ($current == $token->getId()) ? true : false); From c87a1165f68aef363c4bbb26478c94c2458305b7 Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 9 Mar 2021 06:00:19 -0500 Subject: [PATCH 2/3] Update changelog --- CHANGES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 6261981848..d0cd072bc4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,7 +6,7 @@ ## Features -- Better error logs on appwrite cretificates worker +- Better error logs on appwrite certificates worker - Added option for Redis authentication - Force adding a security email on setup - SMTP is now disabled by default, no dummy SMTP is included in setup @@ -28,6 +28,7 @@ - Updated missing storage env vars - Fixed a bug, that Response format header was not added in the access-control-allow-header list. +- Fixed a bug where countryName is unknown on sessions (#933) ## Security From ed447986eaf3f17724146f0771ba6a184ec6fe2f Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 9 Mar 2021 06:03:42 -0500 Subject: [PATCH 3/3] Use uppercase countryCode --- app/controllers/api/users.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index efb0041cee..dbff5a0191 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -205,8 +205,8 @@ App::get('/v1/users/:userId/sessions') continue; } - $token->setAttribute('countryName', (isset($countries[$token->getAttribute('contryCode')])) - ? $countries[$token->getAttribute('contryCode')] + $token->setAttribute('countryName', (isset($countries[strtoupper($token->getAttribute('contryCode'))])) + ? $countries[strtoupper($token->getAttribute('contryCode'))] : $locale->getText('locale.country.unknown')); $token->setAttribute('current', false);