ibm mobilefirst - java.lang.IllegalStateException: Cannot change identity of an already logged in user in realm -
i getting following error while login cannot change identity of logged in user in realm 'adapterauthrealm'. application must logout first.
fwlse0101e: caused by: java.lang.illegalstateexception: cannot change identity of logged in user in realm 'adapterauthrealm'. application must logout first.
my code follows
adapter.js
function submitauthentication(username, password){ serversession = storesession(username); if (username!=""){ var useridentity = { userid: username, displayname: username, attributes: { foo: "bar" } }; wl.server.setactiveuser("adapterauthrealm", useridentity); return { authrequired: false }; } return onauthrequired(null, "invalid login credentials"); } function onlogout(){ wl.server.setactiveuser("adapterauthrealm", null); wl.logger.debug("logged out"); }
client side
wl.client.logout('adapterauthrealm', {onsuccess:wl.client.reloadapp});
before: wl.server.setactiveuser("adapterauthrealm", useridentity);
add: wl.server.setactiveuser("adapterauthrealm", null);
this make sure have clean slate before login in user.
the end result is:
function submitauthentication(username, password) { serversession = storesession(username); if (username !== "") { var useridentity = { userid: username, displayname: username, attributes: { foo: "bar" } }; wl.server.setactiveuser("adapterauthrealm", null); wl.server.setactiveuser("adapterauthrealm", useridentity); return { authrequired: false }; } return onauthrequired(null, "invalid login credentials"); }
Comments
Post a Comment