}
                        }
                    } else {
                        //Redirect to the subscription form
                        header('Location: ' . api_get_path(WEB_CODE_PATH) . 'auth/inscription.php?username='******'openid.sreg.nickname'] . '&email=' . $res['openid.sreg.email'] . '&openid=' . $res['openid.identity'] . '&openid_msg=idnotfound');
                        //$loginFailed = true;
                    }
                } else {
                    $loginFailed = true;
                }
            } else {
                $loginFailed = true;
            }
        }
    } elseif (KeyAuth::is_enabled()) {
        $success = KeyAuth::instance()->login();
        if ($success) {
            $use_anonymous = false;
        }
    }
    $uidReset = true;
}
// end
if ($loginFailed == true && !empty($errorMessage)) {
    header('Location: ' . api_get_path(WEB_PUBLIC_PATH) . 'index?error=' . $errorMessage);
    exit;
}
//Now check for anonymous user mode
if (isset($use_anonymous) && $use_anonymous) {
    //if anonymous mode is set, then try to set the current user as anonymous
    //if he doesn't have a login yet