Pattern for storing credentials for mobile app?


#1

I’d like to store credentials for my mobile app so that the user does not need to re-enter his credentials and re-authenticate when the app is restarted, whether it be because connection timed out or it crashes, the server restarted etc. Basically I’d like it to behave like facebook, twitter etc. apps I’m sure we all have on our phones. Is there a pattern to handle this with Meteor?

I was speculating that I could hack something with Phonegap’s localstorage but I don’t know if there is a known or better way.

Thanks in advance!


#2

Meteor login should already persist through localstorage. Does it not work for you?


#3

hi @sashko… if there is no network connectivity, the app does not switch to local storage… is this the expected behaviour?


#4

The login state is always stored in localstorage, regardless of online state.


#5

If the users device runs out of memory, it is possible that the local storage will be cleared, in this case you should use a Cordova plugin like nativestorage.


#6

Actually I am looking at the use case when I close the mobile app and reopen it.

If there is no network access, my app simply cannot do the login for the user.

Is there some way to persist the auth in case there is no network available on restart of the app.


#7

So you want to have offline access to your subscriptions and user data? Then you should use Ground:DB. We are using it for a messenger app, so the user can access all chats even if he is offline. He also stays “logged in”.


#8

Nice! When online, does it fetch first from local and then go online? So the application would appear fast…


#9

Yes, it automatically syncs if the connection gets established.