Merge pull request #963 from appwrite/fix-933-country-name-unknown-for-sessions

Use uppercase countryCode as index for $countries assoc array
This commit is contained in:
Eldad A. Fux
2021-03-09 15:57:40 +02:00
committed by GitHub
3 changed files with 9 additions and 6 deletions
+2 -1
View File
@@ -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
+5 -3
View File
@@ -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);
+2 -2
View File
@@ -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);