From 7d9daf1ae2d13e766699ae0d69823cd22fc1bf56 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Thu, 12 Apr 2018 22:50:11 +0200 Subject: [PATCH] - added character whitelist to `pathfinder.ini`, closed #611 --- app/main/model/charactermodel.php | 25 ++++++++++++++++++++----- app/pathfinder.ini | 1 + js/app/login.js | 1 + public/js/v1.3.5/app/login.js | 1 + 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/main/model/charactermodel.php b/app/main/model/charactermodel.php index e271bff8..e1314e72 100644 --- a/app/main/model/charactermodel.php +++ b/app/main/model/charactermodel.php @@ -32,6 +32,7 @@ class CharacterModel extends BasicModel { const AUTHORIZATION_STATUS = [ 'OK' => true, // success 'UNKNOWN' => 'error', // general authorization error + 'CHARACTER' => 'failed to match character whitelist', 'CORPORATION' => 'failed to match corporation whitelist', 'ALLIANCE' => 'failed to match alliance whitelist', 'KICKED' => 'character is kicked', @@ -552,25 +553,39 @@ class CharacterModel extends BasicModel { // check whether character is banned or temp kicked if(is_null($this->banned)){ if( !$this->isKicked() ){ + $whitelistCharacter = array_filter( array_map('trim', (array)Config::getPathfinderData('login.character') ) ); $whitelistCorporations = array_filter( array_map('trim', (array)Config::getPathfinderData('login.corporation') ) ); $whitelistAlliance = array_filter( array_map('trim', (array)Config::getPathfinderData('login.alliance') ) ); if( + empty($whitelistCharacter) && empty($whitelistCorporations) && empty($whitelistAlliance) ){ // no corp/ally restrictions set -> any character is allowed to login $authStatus = 'OK'; }else{ + // check if character is set in whitelist + if( + !empty($whitelistCharacter) && + in_array((int)$this->_id, $whitelistCharacter) + ){ + $authStatus = 'OK'; + }else{ + $authStatus = 'CHARACTER'; + } + // check if character corporation is set in whitelist if( + $authStatus != 'OK' && !empty($whitelistCorporations) && - $this->hasCorporation() && - in_array((int)$this->get('corporationId', true), $whitelistCorporations) + $this->hasCorporation() ){ - $authStatus = 'OK'; - }else{ - $authStatus = 'CORPORATION'; + if( in_array((int)$this->get('corporationId', true), $whitelistCorporations) ){ + $authStatus = 'OK'; + }else{ + $authStatus = 'CORPORATION'; + } } // check if character alliance is set in whitelist diff --git a/app/pathfinder.ini b/app/pathfinder.ini index 3a3c75c4..dbab04a4 100644 --- a/app/pathfinder.ini +++ b/app/pathfinder.ini @@ -32,6 +32,7 @@ COOKIE_EXPIRE = 30 MODE_MAINTENANCE = 0 ; restrict login to specific corporations/alliances by id (e.g. 1000166,1000080) +CHARACTER = CORPORATION = ALLIANCE = diff --git a/js/app/login.js b/js/app/login.js index 692fff6d..f1410cfe 100644 --- a/js/app/login.js +++ b/js/app/login.js @@ -616,6 +616,7 @@ define([ case 'UNKNOWN': label = 'ERROR'; break; + case 'CHARACTER': case 'CORPORATION': case 'ALLIANCE': label = 'INVALID'; diff --git a/public/js/v1.3.5/app/login.js b/public/js/v1.3.5/app/login.js index 692fff6d..f1410cfe 100644 --- a/public/js/v1.3.5/app/login.js +++ b/public/js/v1.3.5/app/login.js @@ -616,6 +616,7 @@ define([ case 'UNKNOWN': label = 'ERROR'; break; + case 'CHARACTER': case 'CORPORATION': case 'ALLIANCE': label = 'INVALID';