工作灯 - 如何检查,如果客户端已经登录,然后通过登录界面 [英] Worklight - How to check if a client is already logged in, then pass the login screen
问题描述
我收到以下错误,当我登录我的登录屏幕的第二次。
I get the following error when I log in the second time in my login screen.
[ERROR ] FWLSE0099E: An error occurred while invoking procedure [project Klappr]KlapprAuthAdapter/submitAuthenticationFWLSE0100E: parameters: [project Klappr]{
"arr": [
"dGVzdDp0ZXN0"
]
}
Cannot change identity of an already logged in user in realm 'KlapprAuthRealm'. The application must logout first.
FWLSE0101E: Caused by: [project Klappr]null
com.worklight.common.log.filters.ErrorFilter
在submitauthentication(在适配器),我检查,如果用户名和密码是否正确,如果正确设置我这样在WorklightRealm的activeUser:
In submitauthentication (in the adapter) I check if the username and password are correct and if they are correct I set the activeUser in the WorklightRealm like this:
WL.Server.setActiveUser("KlapprAuthRealm",{
userId:""+teacher.id,
displayName: teacher.voornaam,
credentials:loginstring,
attributes: {
"teacherId": teacher.id,
}
});
我如何检查,如果用户已经登录?这是最好的客户端之前,我展示loginpage?或者我应该让他们能够登录在另一个时间,如果他们已经登录,也返回用户id?
How can I check if the user is already logged in? Is this best on client side before I show the loginpage? Or should I let them be able to log in another time, and if they are already logged in, also return the userId?
推荐答案
这是发生,因为你想设置为有效用户,但它已经被设置。一个可能的解决办法是设置活动的用户以实际用户身份之前调用WL.Server.setActiveUser(KlapprAuthRealm,NULL)。
This is happening because you're trying to set active user but it is already set. A possible solution might be to call WL.Server.setActiveUser("KlapprAuthRealm", null) before setting active user with actual user identity.
这篇关于工作灯 - 如何检查,如果客户端已经登录,然后通过登录界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!