Ibm mobilefirst Android和iUserAuthenticated上的Worklight身份验证问题

Ibm mobilefirst Android和iUserAuthenticated上的Worklight身份验证问题,ibm-mobilefirst,Ibm Mobilefirst,我在Android应用程序中遇到身份验证问题,我使用的是Worklight 5.0.6版 我已使用此身份验证配置创建了一个安全应用程序: <securityTests> <mobileSecurityTest name="Sencha22-Mobile-SecurityTest"> <testDeviceId provisioningType="none"/> <testUser realm="SampleAppR

我在Android应用程序中遇到身份验证问题,我使用的是Worklight 5.0.6版

我已使用此身份验证配置创建了一个安全应用程序:

<securityTests>
    <mobileSecurityTest name="Sencha22-Mobile-SecurityTest">
        <testDeviceId provisioningType="none"/>
        <testUser realm="SampleAppRealm"/>
    </mobileSecurityTest>
</securityTests>

<realms>
    <realm loginModule="StrongDummy" name="SampleAppRealm">
    <className>com.worklight.core.auth.ext.FormBasedAuthenticator</className>
    </realm>
</realms>

<loginModules>
    <loginModule name="StrongDummy">
        <className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
    </loginModule>
</loginModules>
验证发生后,WL.Client.reloadApp()语句正在正确执行,但函数:

WL.Client.isUserAuthenticated("SampleAppRealm")
在Android上总是返回NULL

当在Chrome中被视为公共资源时,该应用程序运行良好


Android上的isUserAuthenticated有问题吗?

首先,我不认为在验证后重新加载应用程序是个好主意。
现在。一旦应用程序连接到WL服务器,就会从该服务器接收身份验证信息。要连接到WL服务器,您需要在initOptions.js中设置connectOnStartup:true或使用WL.Client.connect()API。既然你说这个问题只发生在android上,我猜你有时间问题。确保在客户端成功接收到来自服务器的响应后调用isUserAuthenticated API。

在5.0.6中,isUserAuthenticated将始终返回true或false,并且完全基于javascript(因此无论平台如何,它都应该是一致的)。我想这里发生了别的事情让你得到一个空的。。。是否存在javascript异常?检查的一种方法是在android设备(如weinre)上使用javascript调试库(将javascript文件添加到html中,然后连接到本地服务器以调试控制台输出:)。查看javascript输出中是否抛出任何异常。正如Anton所说,您的设备也可能遇到计时问题


旁注:Anton是正确的:WL.Client.reloadApp()可能会根据设备或浏览器的设置清除身份验证状态。

感谢您的回复,我在initOptions.js文件中有:var wlInitOptions={connectOnStartup:true},并且应用程序在启动时已成功连接。关于排序问题,您可能是正确的,但我想测试isUserAuthenticated(),以便显示应用程序或登录页面。
WL.Client.isUserAuthenticated("SampleAppRealm")