Only one user can login with Authenticate() at the same time

+1 vote
Now, I can login with the same user name at different device at the same time,

I expect only one user can login with Authenticate() at the same time.

How Can I do?

Thanks!
asked May 23, 2014 in App42 Cloud API-BaaS by wuqiudongonmyway (30 points)

1 Answer

+1 vote

Hi Wuqiudongonmyway,

Sorry for late reply. You can use the getSession method of session Service before call Authenticate if you are getting the sessionId means user login in another device. 

answered May 24, 2014 by naresh (350 points)
Hi,thanks!
This means that I have to invalidate the sessionID when close/log out the app,
but if the app is crash, or the phone close the app in a non normal way, this will result the app don't invalidate the sessionID.
The sessionID will be always exist. Before I login in, I will check the sessitionID, and I can't log in forever if sessionID is exist.
how to resolve it? thank you!
Hi Wuqiudongonmyway,

You can easily resolve such kind of query.
First, In this scenario, you can save a json document using No-SQL Storage Service.  In which you can define a key as login and value as session or value as true. So when  ever a user comes to app you set the login value as true and on logout set the value as false.
Second, on every login first you can check the value and owner of the document. On the basis of owner of the document and login value, you can show the error to user or invalidate the session of user. So that only one user can login into app.

Please find the link below for Saving & Query the user data into cloud using No-SQL Storage Service :-
http://api.shephertz.com/tutorial/Saving-App-Data/?index=storage-data
http://api.shephertz.com/tutorial/Querying-Your-App-Data/?index=query-appdata
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...