From 08a831c141eba215a9b66b56a5957aa0709487aa Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Sun, 25 Oct 2020 11:27:07 +0200 Subject: [PATCH] Fixed validation test --- app/controllers/api/account.php | 2 +- app/controllers/api/locale.php | 9 +++------ app/controllers/api/users.php | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 00a3d944d7..eef09de3d4 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -641,7 +641,7 @@ App::get('/v1/account/sessions') try { $record = $geodb->get($token->getAttribute('ip', '')); - if (isset($record)){ + if ($record) { $sessions[$index]['geo']['isoCode'] = \strtolower($record['country']['iso_code']); $sessions[$index]['geo']['country'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown'); } diff --git a/app/controllers/api/locale.php b/app/controllers/api/locale.php index f1d1e0bc86..764a54304b 100644 --- a/app/controllers/api/locale.php +++ b/app/controllers/api/locale.php @@ -29,12 +29,9 @@ App::get('/v1/locale') $currency = null; - try { - $record = $geodb->get($ip); - - var_dump('record'); - var_dump($record); + $record = $geodb->get($ip); + if($record) { $output['countryCode'] = $record['country']['iso_code']; $output['country'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown'); $output['continent'] = (isset($continents[$record['continent']['code']])) ? $continents[$record['continent']['code']] : $locale->getText('locale.country.unknown'); @@ -48,7 +45,7 @@ App::get('/v1/locale') } $output['currency'] = $currency; - } catch (\Exception $e) { + } else { $output['countryCode'] = '--'; $output['country'] = $locale->getText('locale.country.unknown'); $output['continent'] = $locale->getText('locale.country.unknown'); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 6ea3b8f87c..4f629b5686 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -272,7 +272,7 @@ App::get('/v1/users/:userId/sessions') try { $record = $geodb->get($token->getAttribute('ip', '')); - if (isset($record)) { + if ($record) { $sessions[$index]['geo']['isoCode'] = \strtolower($record['country']['iso_code']); $sessions[$index]['geo']['country'] = (isset($countries[$record['country']['iso_code']])) ? $countries[$record['country']['iso_code']] : $locale->getText('locale.country.unknown'); } else {