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 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); 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);