From 513708b11c10f6254ac0cc7a505a4ad4dddc6c72 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 6 Apr 2018 14:42:10 -0400 Subject: [PATCH] don't need to define the config, it will have already been done. Include auth.php instead of functions.php as the code has been moved --- web/api/app/Controller/AppController.php | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/web/api/app/Controller/AppController.php b/web/api/app/Controller/AppController.php index 1c0458c41..7be1cd72a 100644 --- a/web/api/app/Controller/AppController.php +++ b/web/api/app/Controller/AppController.php @@ -76,6 +76,8 @@ class AppController extends Controller { $zmOptAuth = $config['Config']['Value']; if ( $zmOptAuth == '1' ) { + require_once "../../../includes/auth.php"; + $this->loadModel('User'); if ( isset($_REQUEST['user']) and isset($_REQUEST['pass']) ) { $user = $this->User->find('first', array ('conditions' => array ( @@ -92,19 +94,6 @@ class AppController extends Controller { } if ( isset($_REQUEST['auth']) ) { - require_once "../../../includes/functions.php"; - - // Define some defines required by getAuthUser in functions.php - $defines = array('ZM_AUTH_HASH_IPS', 'ZM_AUTH_HASH_SECRET', 'ZM_AUTH_RELAY', 'ZM_OPT_USE_AUTH'); - $configQuery = array( - 'conditions' => array('OR' => array('Name' => $defines)), - 'fields' => array('Name', 'Value') - ); - $config = $this->Config->find('list', $configQuery); - - foreach ($defines as $define) { - define($define, $config[$define]); - } $user = getAuthUser($_REQUEST['auth']); if ( ! $user ) { @@ -134,9 +123,8 @@ class AppController extends Controller { $this->Session->Write('controlPermission',$userMonitors['User']['Control']); $this->Session->Write('systemPermission',$userMonitors['User']['System']); $this->Session->Write('monitorPermission',$userMonitors['User']['Monitors']); - } - else // if auth is not on, you can do everything - { + } else { + // if auth is not on, you can do everything //$userMonitors = $this->User->find('first', $options); $this->Session->Write('allowedMonitors',''); $this->Session->Write('streamPermission','View');