2

在我的旅行中,让使用 Janrain 客户端身份验证过程对用户进行身份验证的整个过程正常工作,这是一次漫长的奇怪之旅,但我终于让它工作了,但是......

如何在获得令牌后关闭模式弹出窗口,然后针对我的 WebApi 控制器之一使用 $.ajax get 方法获取用户信息?

整个过程效果很好,我得到了我需要的用户个人资料信息,但是在对我的 WebApi 控制器执行我的 ajax 调用并用数据填充我的页面上的 div 标签后,模态窗口仍然打开,并且在 Facebook 徽标下显示状态说“在登录....”

我还不允许发布图像,但如果您想查看冻结模式的图像,可以在此处查看“http://oi46.tinypic.com/34s1nax.jpg”

帮助!我是否错过了关闭模式的最后一个命令?

这是我的一些代码。

(function () {
if (typeof window.janrain !== 'object') window.janrain = {};
window.janrain.settings = {};

janrain.settings.tokenUrl = 'http://localhost:20000/login.html';
janrain.settings.tokenAction = 'event';
janrain.settings.type = 'modal';
janrain.settings.linkClass = 'janrainEngage';


function isReady() { janrain.ready = true; };
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", isReady, false);
} else {
    window.attachEvent('onload', isReady);
}

var e = document.createElement('script');
e.type = 'text/javascript';
e.id = 'janrainAuthWidget';

if (document.location.protocol === 'https:') {
    e.src = 'https://rpxnow.com/js/lib/idrinkticket/engage.js';
} else {
    e.src = 'http://widget-cdn.rpxnow.com/js/lib/idrinkticket/engage.js';
}

var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(e, s);
})();



function janrainWidgetOnload() {
janrain.events.onProviderLoginStart.addHandler(function () {
    console.log('Login Start!');
});
janrain.events.onProviderLoginComplete.addHandler(function (response) {
    console.log('Login complete!');
    console.log('response.provider = ' + response.provider);
});
janrain.events.onProviderLoginError.addHandler(function (response) {
    console.log('Login Error!');
    console.log('response.err.code = ' + response.err.code);
    console.log('response.err.msg = ' + response.err.msg);
    console.log('response.origin = ' + response.origin);
    console.log('response.state = ' + response.state);
});
janrain.events.onProviderLoginSuccess.addHandler(function (something) {
    console.log('Login Succcess!');
});
janrain.events.onReturnExperienceFound.addHandler(function (response) {
    console.log('Return Experience Found!');
    console.log('response.name = ' + response.name);
    console.log('response.returnProvider = ' + response.returnProvider);
    console.log('response.welcomeName = ' + response.welcomeName);
});
janrain.events.onProviderLoginToken.addHandler(function (response) {
    console.log('Provider Login Token Returned!');
    console.log('response.token = ' + response.token);

    $.ajax({
        url: "http://localhost:30001/Engage",
        type: "get",
        data: ({ token: response.token }),
        dataType: "json",
        success: function (data) {
            $('#results').append(data.Identifier);
            $('#results').append(data.ProviderName);
            $('#results').append(data.DisplayName);
        },
        error: function (xhr, status, p3, p4) {
            console.log(xhr);
            console.log(status);
            console.log(p3);
        }
    });
});
}



<a class="janrainEngage" href="#">LOGIN</a>
<br /><br />

<div id="results"></div>
4

2 回答 2

3

您可以janrain.engage.signin.modal.close()在成功或错误时使用

于 2012-12-06T02:17:15.357 回答
1

也试试这个,

janrain.events.onProviderLoginComplete.addHandler(function (response) {
    janrain.engage.signin.modal.close();
});
于 2015-11-17T19:23:57.477 回答