ibm mobilefirst - How to get the userIdentity of the user being logged out when using Worklight adapter based authentication -


i implementing adapter based authentication worklight application. record, using worklight version 5.0.6.1.

what is, seems advised in documentation, perform cleanup in "logout" function of authentication adapter.

thus, inside logout function being called automatically worklight framework, i'd retrieve useridentity object holding info user being logged out. tried achieve calling "wl.server.getactiveuser()", not seem possible in logout function.

i can see following exception in logs (websphere app server 7):

[9/3/13 17:13:11:683 ist] 00000039 dataaccessser 1        com.worklight.integration.services.impl.dataaccessserviceimpl invokeprocedureinternal procedure 'onlogout' invocation failed. runtime: adapter 'onlogout' security test has no user realm.java.lang.runtimeexception: adapter 'onlogout' security test has no user realm. 

the idea behind want call external rest service perform cleanup in db, , need mobile application userid passed parameter of service.

could please give best practices in order retrieve identity of user being logged out inside authentication adapter logout function?

thanks.

user identity destroyed underlying auth framework before adapter.onlogout() invoked. result when adapter.onlogout() called user identity doesn't exist more. therefore wl.server.getactiveuser() return null or throw exception (in case because doesn't have user realm defined, fine).

in case still require data useridentity after underlying auth framework discards (and case) can save useridentity in session state. need remember since you're manually storing there - responsibility wipe once not required anymore.

so adapter code like:

/* global var, not inside of function*/ var useridentity = null;  function submitcredentials(user, pass){     if (/*validate credentials*/){          /* using created global var, not declaring again */         useridentity = {              userid:user,              displayname:user         };         wl.server.setactiveuser("realm", useridentity);     } }  function onlogout(){     /* stuff useridentity object , wipe it*/     useridentity = null; } 

the main difference regular adapter flow useridentity object not created in scope of submitcredentials() function global variable, therefore session scoped var.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -