登录重定向在Firefox中显示白色页面

时间:2012-05-09 作者:Jeroen

我正在开发一个插件,允许将本地wordpress帐户链接到双因素身份验证服务。

在Chrome和IE中,登录和链接流程可以完美工作,但重定向会导致Firefox中出现白色页面。奇怪的是,没有任何错误,因为所有代码都已执行,页面的简单F5刷新将显示正确的页面。

正如您在下面的代码中所看到的,我只使用了一次wp\\u redirect()来触发身份验证流,这是可行的,不是问题所在。从那以后,Wordpress将处理所有重定向,在Chrome和IE中表现出色,但在Firefox中却失败了

public function myplugin_callback() {
    global $wp_query;

    if ($wp_query->get(\'code\')) {
        $_SESSION[\'code\'] = $wp_query->get(\'code\');
        $_SESSION[\'state\'] = $wp_query->get(\'state\');

        wp_redirect(site_url(\'wp-login.php\', \'login\'));
        echo \'Please wait, logging in.\';
        exit;
    }
}

public function myplugin_authenticate($user, $username) {
    // do the authentication here
    if (isset($_SESSION[\'code\'])) {
        /* get userdata via OAuth here */

        if (isset($userData[\'email\'])) {
            $userSearch = get_user_by(\'email\', $userData[\'email\']);

            if ($userSearch) { // user exists
                $uuid = get_user_meta($userSearch->ID, \'myplugin_uuid\', true);
                if ($uuid == $userData[\'uuid\']) { // user is linked
                    $user = new WP_User($userSearch->ID);
                } else { // user is not linked
                    $_SESSION[\'myplugin-data\'] = serialize($userData);
                    $user = new WP_Error(\'denied\', __(\'You already have an account with this email on this blog. Please log in to link this account with our service.\'));
                    remove_action(\'authenticate\', \'wp_authenticate_username_password\', 20);
                }
            } else { // user does not exist
                $user = new WP_Error();
            }
        }
        unset($_SESSION[\'code\']);
    } else { // local login
        $userSearch = get_user_by(\'login\', $username);

        if ($userSearch) {
            $uuid = get_user_meta($userSearch->ID, \'myplugin_uuid\', true);

            if (!isset($_SESSION[\'myplugin-data\']) && !empty($uuid) && !$this->myPluginHelper()->getlocalAuthAllowed()) {
                $user = new WP_Error(\'denied\', __(\'Local login disabled. Please use myPlugin to log in.\'), \'message\');
                remove_action(\'authenticate\', \'wp_authenticate_username_password\', 20);
            } else {
                add_filter(\'login_redirect\', array($this, \'save_myplugin_uuid\'), 10, 3);
            }
        }
    }
    return $user;
}

public function save_myplugin_uuid($redirect_to, $request, $user) {
    if (isset($_SESSION[\'myplugin-data\']) && is_a($user, \'WP_User\')) {
        $userData = unserialize($_SESSION[\'myplugin-data\']);
        update_usermeta($user->ID, \'myplugin_uuid\', $userData[\'uuid\']);
        unset($_SESSION[\'myplugin-data\']);
    }
    return $redirect_to;
}
我在谷歌上搜索了很多交易,但都没有用。有人有主意吗?

ThanksJeroen谢谢

1 个回复
SO网友:Jeroen

正如我所想(并在Chrome和IE上进行了测试),代码坚如磐石。

这原来是我们公司代理人的问题。

结束

相关推荐

wp_login_form redirect

是否有方法将使用wp\\u login\\u表单登录的用户重定向到注册时自动创建的自定义页面似乎URL需要是绝对的,很明显URL的结尾会随着每个用户的不同而变化。请参阅用于在注册时创建页面的函数function create_user_page($user_id) { if ( $user = get_userdata($user_id) ) { // Create a new user-specific page $page = array