Search code examples
authenticationmeteoraccounts

Meteor Accounts Resume Token "Remember Me"


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"

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
  • setup
    • rememberMe.config.days = 9999
    • rememberMe.config.storageClient = localStorage

NOTE: this is related to Meteor Accounts autologin pattern?

Recommendations?


Solution

  • 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