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 );
}