Unknown realm [myRealm]. null returned for key: isUserAuthenticated

独自空忆成欢 提交于 2019-12-22 00:31:12

问题


I am using IBM Worklight 6.1 and trying to check if the user is authenticated or not:

I have a Realm defined in server/conf/authenticationConfig.xml

<realm name="myRealm" loginModule="myLoginModule">
<className>com.worklight.integration.auth.AdapterAuthenticator</className>
<parameter name="login-function" value="authentication.onAuthRequired" />
<parameter name="logout-function" value="authentication.onLogout" />
</realm>

and its login module

<loginModule name="myLoginModule">
<className>com.worklight.core.auth.ext.NonValidatingLoginModule</className>
</loginModule>

and after logging in, or even before that, when I try to check if the user is authenticated or not using

WL.Client.isUserAuthenticated("myRealm")

I have the following response

 Unknown realm [myRealm]. null returned for key: isUserAuthenticated 

Anyone have an idea about that ? Is there something wrong with my Realm definition ? Is there a better way to check if a user is authenticated ?


回答1:


Did you first call to WL.Client.updateUserInfo();?

From the documentation:

updateUserInfo(options)

This method refreshes user data after an exception. Use this method when the application receives an exception after calling the invokeProcedure() method. The method refreshes the data for the following methods:

WL.Client.getUserName(realm)
WL.Client.getLoginName(realm)
WL.Client.isUserAuthenticated(realm)

After such an exception, you can verify the user authentication status by calling this function first, and then the isUserAuthenticated() method.

Parameters: options - Optional. A standard options object.



来源:https://stackoverflow.com/questions/23593729/unknown-realm-myrealm-null-returned-for-key-isuserauthenticated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!