2016-02-04 181 views
0

阅读Janrain文档我发现,要责成janrain登录(http://developers.janrain.com/reference/javascript-api/registration-js-api/settings/#registration-flow)后重定向两个属性:Janrain - 登录后重定向

redirectOnLogin - 将其设置为启用或禁用。仅当此值设置为启用时才会使用redirectUri。

redirectUri - 设置成功注册或登录后重定向的URL。

我试图设置janrain演示网站(http://demos.janrain.com/JanrainDemoSites/)这两个属性:

janrain.settings.capture.redirectOnLogin = 'enabled'; 
janrain.settings.capture.redirectUri = 'http://demos.janrain.com/test'; 

但我没有得到登录后重定向。 我错过了什么吗?

谢谢。

回答

1

使用Janrain注册部件成功登录后最可靠的(并且在我看来是最好的)重定向方式是使用Javascript事件处理程序。

对于“标准”窗口小部件配置(无SSO或任何其他集成),你可以使用下面的事件处理程序来执行你的重定向:

janrain.events.onCaptureLoginSuccess.addHandler(function(result) { 
    if (window.console && window.console.log) console.log(result); 
    document.location = http://someserverandurlsomewhere.com   
}); 

janrain.events.onCaptureRegistrationSuccess.addHandler(function(result) { 
    if (window.console && window.console.log) console.log(result); 
    document.location = http://someserverandurlsomewhere.com   
}); 

根据版本您可以通过确保janrain-init.js文件中的以下行未注释来将所有事件处理程序记录到浏览器控制台:

janrainUtilityFunctions().showEvents(); 

记录所有事件后,您可以查看成功登录或注册后发生的最终事件。您希望确保在完成所有必需的小部件事件之前不会重定向。例如,如果您使用的是SSO,那么通常会有一些额外的SSO事件在上述两个事件之后被触发。在SSO事件被触发之前重定向将阻止SSO会话正确设置。

希望这会有所帮助。