1
0
Fork 0
mirror of synced 2024-06-23 08:40:58 +12:00

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
commit e22d35b827
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

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

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

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