0

I have a requirement in my application for iOS and Android, developed using IBM Worklight, to remember the user ID if the user selected this option.

I can achieve this by using localStorage, but the issue is that I have two login pages:

  • One is placed within the application, and the
  • Second is hosted on a remote server

Depending on the conditions the application will meet, either the remote login page will be displayed or the local login page will be displayed.

If I use localStorage on local page it is not accessible for server side login page. So I want to use some storage/file on the mobile to store my user id which is accessible for both local and server login page. Is this is possible using worklight/phonegap storage?

More explanation:

Remote login page is hosted on some www.xxx.com domain. My requirement is on launch of application the local login page is shown to the user, there user can enter user id and password and selects remember me option and submits form. Then user logs in and navigated to some xxx.com/yyy server page. From there when user clicks on log out it navigates to remote login page which is hosted on www.xxx.com server. As user already checked remember me option in local page the remote login page has to pre populate the user id text box. And same scenario should happen when user enters credentials in remote login page and selects remember me check box. So when user kills the application from background and relaunches the application user will get local login page where I need to pre populate the user id last time he entered.

user3878988
  • 761
  • 3
  • 8
  • 20
  • Using Local storage on file (native) or browser, wouldn't allow the Server to get this data anyway... What do you mean by "accessible for both local and server login page"? – Ivan Seidel Oct 30 '14 at 02:10
  • Add more information about the "remote login page" -- how do you intend to display it? is it part of the adapter-based authentication in your app or otherwise? Need more information. – Idan Adar Oct 30 '14 at 05:51
  • updated my question. Please let me know if it is not clear.Thanks. – user3878988 Oct 30 '14 at 13:31
  • Can the remote login page get parameters in the URL? – Raanan Avidor Oct 30 '14 at 13:45
  • Yes, it will get. That way I achieved pre populating the user id in remote login page that entered in local page. But I am thinking how I can get the user id that entered in remote login page to local page. – user3878988 Oct 30 '14 at 13:58
  • The localStorage is sandboxed for the specific application. If you want to *save* the username you enter in a REMOTE login page and have it available for the LOCAL login page by retrieving it, I don't think this is possible -- as I think it is a stored in a *different* sandbox. I do not think this course of action valid. Can you edit the question with some more specific or more details for the scenario you are trying to accomplish? – Idan Adar Oct 31 '14 at 13:03

1 Answers1

0

Short answer: in my opinion, no.

Longer answer: I will explain what I think using your scenario:

Remote login page is hosted on some www.xxx.com domain. My requirement is on launch of application the local login page is shown to the user, there user can enter user id and password and selects remember me option and submits form.

So far so good. You can store it in either Web Storage or JSONStore or use Cordova File API. Catch: all of these are available ONLY for the specific application.

Then user logs in and navigated to some xxx.com/yyy server page. From there when user clicks on log out it navigates to remote login page which is hosted on www.xxx.com server. As user already checked remember me option in local page the remote login page has to pre populate the user id text box.

Still plausible. Lets say the user selected 'Remember Me', so you can adjust the URL pointing to the remote login page and send with it as parameters the username and password. Assuming that there will a mechanism to handle those on the remote page.

This does not come for free, though.

And same scenario should happen when user enters credentials in remote login page and selects remember me check box. So when user kills the application from background and relaunches the application user will get local login page where I need to pre populate the user id last time he entered.

This is also a problem IMO, because any application is sandboxed - be it the browser app or the Worklight app, each of them is sandboxed. so you can't just go to website X, and create some localStorage for it and expect that data to be available for another WebView belonging to another app. That's the whole point of sandboxing, in order to protect the app.

And in this case, where the remote "page" will save the data, only Web Storage is available anyway, as JSONStore requires the Worklight API, which is not available when you load external websites.

Notes:

Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89