Exemplo n.º 1
0
/**
* Submit login data
* @ingroup pages
* - check login / password
* - probably send notification-mail
*/
function loginFormSubmit()
{
    global $PH;
    global $auth;
    global $g_languages;
    global $g_valid_login_params;
    ### get formdata ####
    $name = get('login_name');
    $password = get('login_password');
    if (!is_null(get('login_password'))) {
        $password_md5 = md5(get('login_password'));
    } else {
        if (!is_null(get('login_password_md5'))) {
            # required for auto login
            $password_md5 = get('login_password_md5');
        }
    }
    /**
     * try to login using ldap
     */
    if ($auth->checkLdapOption($name)) {
        if ($auth->tryLoginUserByLdap($name, $password)) {
            $PH->messages = array();
            $auth->storeUserCookie();
            if (isset($g_languages[$auth->cur_user->language])) {
                setLang($auth->cur_user->language);
            }
            ### display taskView ####
            $projects = $auth->cur_user->getProjects();
            ### if go-parameter was present before logging in
            if ($go_after = get('go_after')) {
                $params = array();
                foreach ($g_valid_login_params as $var) {
                    if (get($var)) {
                        $params[$var] = get($var);
                    }
                }
                log_message("show(go_after=" . get('go_after') . ")", LOG_MESSAGE_DEBUG);
                $PH->show(get('go_after'), $params);
            } else {
                if (count($projects) == 1) {
                    setWelcomeToProjectMessage($projects[0]);
                    $PH->show('projView', array('prj' => $projects[0]->id));
                } else {
                    $PH->messages[] = sprintf(__("Welcome to %s", "Notice after login"), confGet('APP_NAME'));
                    $PH->show('home', array());
                }
            }
        } else {
            log_message("invalid login. Show loginForm again", LOG_MESSAGE_DEBUG);
            $PH->messages[] = __('invalid login', 'message when login failed');
            $PH->show('loginForm');
        }
    } else {
        /**
         * try to login with nickname / password
         */
        if ($auth->tryLoginUser($name, $password_md5)) {
            $PH->messages = array();
            $auth->storeUserCookie();
            if (isset($g_languages[$auth->cur_user->language])) {
                setLang($auth->cur_user->language);
            }
            ### display taskView ####
            $projects = $auth->cur_user->getProjects();
            ### if go-parameter was present before logging in
            if ($go_after = get('go_after')) {
                $params = array();
                foreach ($g_valid_login_params as $var) {
                    if (get($var)) {
                        $params[$var] = get($var);
                    }
                }
                log_message("show(go_after=" . get('go_after') . ")", LOG_MESSAGE_DEBUG);
                $PH->show(get('go_after'), $params);
            } else {
                if (count($projects) == 1) {
                    setWelcomeToProjectMessage($projects[0]);
                    $PH->show('projView', array('prj' => $projects[0]->id));
                } else {
                    $PH->messages[] = sprintf(__("Welcome to %s", "Notice after login"), confGet('APP_NAME'));
                    $PH->show('home', array());
                }
            }
        } else {
            log_message("invalid login. Show loginForm again", LOG_MESSAGE_DEBUG);
            $PH->messages[] = __('invalid login', 'message when login failed');
            $PH->show('loginForm');
        }
    }
}
Exemplo n.º 2
0
            $PH->show($requested_page->id);
            exit;
        } else {
            echo __('Sorry. Authentication failed');
            exit;
        }
    }
}
### valid user or anonymous user ###
if ($user) {
    ### if no target-page show home ###
    if (!$requested_page_id) {
        ### if user has only one project go there ###
        $projects = $auth->cur_user->getProjects();
        if (count($projects) == 1) {
            setWelcomeToProjectMessage($projects[0]);
            $PH->show('projView', array('prj' => $projects[0]->id));
        } else {
            new FeedbackMessage(sprintf(__("Welcome to %s", "Notice after login"), confGet('APP_NAME')));
            $PH->show('home', array());
        }
        exit;
    }
    $PH->show($requested_page_id);
    exit;
} else {
    if ($requested_page_id && $requested_page && $requested_page->valid_for_anonymous) {
        $PH->show($requested_page_id);
        exit;
    } else {
        if (get('tuid') && $requested_page && $requested_page->valid_for_tuid) {