0
votes

As per my client requirement I have to implement auto logout on Session timeout. To Implement this I have created a timer on client side which for every minute checks if user is still authenticated. If user is not authenticated then display message and route user back to login page.

So I set up my application is Session dependent mode. I have updated worklight properties like this.

mfp.session.independent=false
mfp.attrStore.type=httpSession
serverSessionTimeout=10

I have also update authenticationConfig.xml where I have set expirationInSeconds As mentioned in this (documentation) https://www.ibm.com/support/knowledgecenter/SSHS8R_7.1.0/com.ibm.worklight.dev.doc/devref/r_configuring_login_modules.html

<loginModule name="CustomLoginModule" expirationInSeconds="-1">

I read couple of other threads and found that every minute I can call WL.Client.isUserAuthenticated("MyReleam") and check if user is still logged in. There is issue with this method it does not sync with server so we are suppose to call WL.Client.updateUserInfo() first which will sync the user identity with server then check for authentication, but it brings another issue with session time out.If every minute I call WL.Client.updateUserInfo() it will extend my session. So basically session will never time out if I keep checking every minute.

Can any one help me to know how can I achieve this functionality? Which method should I use to check if user is still authentication or session is timed out or not.

1

1 Answers

0
votes

I think the application experience can be looked at from a different angel.
Simply let the session timeout value run its course.

Once the session timeout was reached, this means that upon the next request the client sends to the server, the server will challenge the app again.

Why at all bother with forcing the application to move to the login screen artificially? Let the server session do what it is supposed to do.

Otherwise, do not at all bother to "sync". Keep a timer running on the app.
Whenever the user does an "action", reset it. If the user will not do any action, the timer will reach its goal and then force a logout on the client-side.