diff --git a/restapi/index.php b/restapi/index.php index 982b9f98a..dfc14ad23 100644 --- a/restapi/index.php +++ b/restapi/index.php @@ -63,7 +63,7 @@ class RestapiController { /* {{{ */ } } return $attrvalues; - } /* }}} */ + } /* }}} */ protected function __getDocumentData($document) { /* {{{ */ $data = array( @@ -232,6 +232,7 @@ class RestapiController { /* {{{ */ $dms = $this->container->dms; $settings = $this->container->config; $logger = $this->container->logger; + $authenticator = $this->container->authenticator; $params = $request->getParsedBody(); if(empty($params['user']) || empty($params['pass'])) { @@ -240,23 +241,7 @@ class RestapiController { /* {{{ */ } $username = $params['user']; $password = $params['pass']; - - // $userobj = $dms->getUserByLogin($username); - $userobj = null; - - /* Authenticate against LDAP server {{{ */ - if (!$userobj && isset($settings->_ldapHost) && strlen($settings->_ldapHost)>0) { - require_once("../inc/inc.ClassLdapAuthentication.php"); - $authobj = new SeedDMS_LdapAuthentication($dms, $settings); - $userobj = $authobj->authenticate($username, $password); - } /* }}} */ - - /* Authenticate against SeedDMS database {{{ */ - if(!$userobj) { - require_once("../inc/inc.ClassDbAuthentication.php"); - $authobj = new SeedDMS_DbAuthentication($dms, $settings); - $userobj = $authobj->authenticate($username, $password); - } /* }}} */ + $userobj = $authenticator->authenticate($username, $password); if(!$userobj) { setcookie("mydms_session", '', time()-3600, $settings->_httpRoot); @@ -2712,6 +2697,7 @@ $container['conversionmgr'] = $conversionmgr; $container['logger'] = $logger; $container['fulltextservice'] = $fulltextservice; $container['notifier'] = $notifier; +$container['authenticator'] = $authenticator; $app->add(new Auth($container)); // Make CORS preflighted request possible @@ -2799,11 +2785,11 @@ $app->get('/echo/{data}', \TestController::class.':echoData'); $app->get('/statstotal', \RestapiController::class.':getStatsTotal'); if(isset($GLOBALS['SEEDDMS_HOOKS']['initRestAPI'])) { - foreach($GLOBALS['SEEDDMS_HOOKS']['initRestAPI'] as $hookObj) { - if (method_exists($hookObj, 'addRoute')) { - $hookObj->addRoute($app); - } - } + foreach($GLOBALS['SEEDDMS_HOOKS']['initRestAPI'] as $hookObj) { + if (method_exists($hookObj, 'addRoute')) { + $hookObj->addRoute($app); + } + } } $app->run();