ground-db icon indicating copy to clipboard operation
ground-db copied to clipboard

Offline method calls when reconnect doesn't authenticate

Open emgee3 opened this issue 11 years ago • 4 comments
trafficstars

When a client connects and the GroundDB is populated, it allows offline work, which is pretty spectacular.

My concern is let's say the auth tokens are expired on the server while the client is offline, after reconnecting the method calls are run, but without a Meteor.userId, the server doesn't accept the changes. So all the offline work is lost.

You can test this by visiting http://grounddb.meteor.com/, logging in, disconnecting, queuing up some methods, manually modifying the auth-token (to simulate a server-side expiration), then reloading the page. All the offline changes are lost.

Is there a pattern for preventing the queued method calls from running until a Meteor.userId exists? If this were resolved, GroundDB would exactly fit a project I am about to start working on.

emgee3 avatar May 11 '14 01:05 emgee3

@emgee3 Good question, I'm not sure removing the local storage auth token is the proper test for this situation. I could make a button triggering "logout all other users" so if the server does a logout all other users thereby invalidating the auth token - what would/ should happen when a user tries to login in - should it be rejected or relogin.

Solving your issue requires:

  1. Allowing seperated localstorage pr. user for outstanding methods
  2. Better conflict handling - making sure not to overwrite new data with old data etc.

I would also like to abstract away from sync local storage into local "storage adapters" opening a wide support, specially for cordova's "unlimited" storage.

I have a small dream to get time/money enough to refactor the groundDB package.

raix avatar May 11 '14 07:05 raix

@emgee3 ground:db lets meteor run the login method - so I think we should be good - but I'm keeping this issue open for inspiration writing more stuff in the new automated qa tests

raix avatar Sep 19 '14 19:09 raix

Nice @raix !

With 1st party Cordova support in Meteor now, this is especially exciting.

emgee3 avatar Sep 19 '14 23:09 emgee3

http://grounddb.meteor.com/ is just updated - I'll see if I can find a safe way to resume methods when user login have returned. Normally grounddb should wait until resuming methods - since its not really in a rush. So the login method should be called before login.

For the case where the login method have returned and the user is still logged out - This is part of a bigger thing related to #58

I guess one could set a flag that method resume would be namespaced pr. user - so methods run while logged in will wait until logged in again. I'm not sure if thats the feature almogdesign is requesting - or if its about securing offline data even more.

raix avatar Dec 21 '14 22:12 raix