public function __construct($domainSerial, $userId = 0) { $this->container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer'); $this->rootDA = $this->container->getDataAccess(); $this->domainserial = $domainSerial; $this->userid = $userId; $domain = $this->container->getCurrentDomain(); if (!is_object($domain)) { $domain_query = $this->rootDA->execute('SELECT domainid FROM domains WHERE id=' . $domainSerial); $domain = new \Innomatic\Domain\Domain($this->rootDA, $domain_query->getFields('domainid'), null); } $this->domainDA = $domain->getDataAccess(); if ($this->userid != 0) { // @todo to be cached in a more elegant way eg. registry if (isset($GLOBALS['gEnv']['runtime']['innomatic']['users']['username_check'][(int) $this->userid])) { $this->username = $GLOBALS['gEnv']['runtime']['innomatic']['users']['username_check'][(int) $this->userid]; $this->userExists = true; } else { $uquery = $this->domainDA->execute('SELECT username FROM domain_users WHERE id=' . (int) $this->userid); if ($uquery->getNumberRows() > 0) { $this->username = $uquery->getFields('username'); $GLOBALS['gEnv']['runtime']['innomatic']['users']['username_check'][(int) $this->userid] = $this->username; $uquery->free(); $this->userExists = true; } } } }
function tenant_login_login($eventData) { $container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer'); $username = $eventData['username']; // Handle the case when the root user tries to login from the tenant login form if (strcmp($username, 'root') === 0) { require_once 'innomatic/desktop/auth/DesktopRootAuthenticatorHelper.php'; \Innomatic\Desktop\Auth\root_login_login($eventData); $response = \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getProcessor()->getResponse(); $response->sendRedirect($container->getBaseUrl(false) . '/root/'); $response->flushBuffer(); return; } $domainId = \Innomatic\Domain\User\User::extractDomainID($username); // Checks it it can find the domain by hostname if (!strlen($domainId)) { $domainId = \Innomatic\Domain\Domain::getDomainByHostname(); if (strlen($domainId)) { $username .= '@' . $domainId; } } // If no domain is found when in Multi Tenant edition, it must be reauth without // checking database, since no Domain can be accessed. if (!strlen($domainId)) { DesktopDomainAuthenticatorHelper::doAuth(true); } $tmpDomain = new \Innomatic\Domain\Domain($container->getDataAccess(), $domainId, null); $domainDA = $tmpDomain->getDataAccess(); $userQuery = $domainDA->execute('SELECT * FROM domain_users WHERE username='******' AND password='******'password']))); // Check if the user/password couple exists if ($userQuery->getNumberRows()) { // Check if the user is not disabled if ($userQuery->getFields('disabled') == $container->getDataAccess()->fmttrue) { DesktopDomainAuthenticatorHelper::doAuth(true, 'userdisabled'); } else { // Login ok, set the session key \Innomatic\Desktop\Controller\DesktopFrontController::instance('\\Innomatic\\Desktop\\Controller\\DesktopFrontController')->session->put('INNOMATIC_AUTH_USER', $username); $innomaticSecurity = new \Innomatic\Security\SecurityManager(); $innomaticSecurity->logAccess($username, false, false, $_SERVER['REMOTE_ADDR']); unset($innomaticSecurity); } } else { DesktopDomainAuthenticatorHelper::doAuth(true); } // unset( $INNOMATIC_ROOT_AUTH_USER ); }
function login_login($eventData) { $container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer'); $username = $eventData['username']; $domainId = \Innomatic\Domain\User\User::extractDomainID($username); // Checks it it can find the domain by hostname if (!strlen($domainId)) { $domainId = \Innomatic\Domain\Domain::getDomainByHostname(); if (strlen($domainId)) { $username .= '@' . $domainId; } } // If no domain is found when in Multi Tenant edition, it must be reauth without // checking database, since no Domain can be accessed. if (!strlen($domainId)) { DesktopDomainAuthenticatorHelper::doAuth(true); } $tmpDomain = new \Innomatic\Domain\Domain($container->getDataAccess(), $domainId, null); $domainDA = $tmpDomain->getDataAccess(); $userQuery = $domainDA->execute('SELECT * FROM domain_users WHERE username='******' AND password='******'password']))); // Check if the user/password couple exists if ($userQuery->getNumberRows()) { // Check if the user is not disabled if ($userQuery->getFields('disabled') == $container->getDataAccess()->fmttrue) { DesktopDomainAuthenticatorHelper::doAuth(true, 'userdisabled'); } else { // Login ok, set the session key \Innomatic\Desktop\Controller\DesktopFrontController::instance('\\Innomatic\\Desktop\\Controller\\DesktopFrontController')->session->put('INNOMATIC_AUTH_USER', $username); $innomaticSecurity = new \Innomatic\Security\SecurityManager(); $innomaticSecurity->logAccess($username, false, false, $_SERVER['REMOTE_ADDR']); unset($innomaticSecurity); } } else { DesktopDomainAuthenticatorHelper::doAuth(true); } // unset( $INNOMATIC_ROOT_AUTH_USER ); }