예제 #1
0
        SimpleSAML_Utilities::redirect($url, array('AuthState' => $authState));
        exit;
    } else {
        $errorCode = "wrongotp";
        if (strpos($result, ":") !== false) {
            $elems = explode(":", $result);
            $attemptsLeft = $elems[1];
        }
    }
} elseif ($type == 'userpass' && !empty($username) && !empty($password)) {
    // attempt user-password login
    $errorCode = sspmod_authTiqr_Auth_Source_TiqrUserPass::handleUserPassLogin($authStateId, $username, $password);
} else {
    $errorCode = NULL;
    // Initialize a new Tiqr session.
    $state[sspmod_authTiqr_Auth_Tiqr::SESSIONKEYID] = sspmod_authTiqr_Auth_Tiqr::startAuthenticationSession($userId, $state);
    SimpleSAML_Auth_State::saveState($state, sspmod_authTiqr_Auth_Tiqr::STAGEID);
}
$globalConfig = SimpleSAML_Configuration::getInstance();
$t = new SimpleSAML_XHTML_Template($globalConfig, 'authTiqr:loginuserpass.php');
$t->data['type'] = $type;
$t->data['stateparams'] = array('AuthState' => $authStateId);
$t->data['errorcode'] = $errorCode;
$t->data['username'] = $username;
if ($attemptsLeft != NULL) {
    $t->data['attemptsLeft'] = $attemptsLeft;
}
$t->data['verifyLoginUrl'] = SimpleSAML_Module::getModuleURL('authTiqr/verify.php', $t->data['stateparams']);
$t->data['mobileDevice'] = preg_match('/iphone/i', $_SERVER["HTTP_USER_AGENT"]) || preg_match('/android/i', $_SERVER["HTTP_USER_AGENT"]);
if ($t->data['mobileDevice']) {
    $returnUrl = SimpleSAML_Module::getModuleURL('authTiqr/complete.php') . '?' . http_build_query($t->data['stateparams']);