Reputation: 2209
I'm building a Meteor + Cordova app where I want sign-in to "stick forever" on the mobile device.
I see the following tutorial whereby I can setup my own custom "resume handler"
Accounts.registerLoginHandler
Accounts._generateStampedLoginToken
Accounts._hashStampedToken
I'll probably write my own (janky) implementation of the above functions and try to get it working, probably storing in localStorage on the client... but I thought I'd ask here to see if anyone knew of a specific solution to this wrapped as package, or a clean example.
Ideally:
meteor add xxxxx:rememberme
rememberMe.config.days = 9999
rememberMe.config.storageClient = localStorage
NOTE: this is related to Meteor Accounts autologin pattern?
Recommendations?
Upvotes: 6
Views: 4749
Reputation: 31
This mbanting:cordova-accounts-resume package will help resolve this by saving the loginToken on the file system, to be used if localStorage is cleared out before the app resumes.
Upvotes: 3
Reputation: 5000
How about using the built-in Accounts.config(options) http://docs.meteor.com/#accounts_config
Accounts.config({
loginExpirationInDays: null
})
Once logged in, it will never expire until the user logout again with Meteor.logout();
However, be aware that since the token is stored in localstorage, it get cleaned sometimes automatically by iOS or android
Upvotes: 4