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
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,
}
});
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?
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.
If you want to check on the client side for before submission:
May want to read the docs on the WL.Client.createChallengeHandler to handle the session and login flow