Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"

  • https://meteorhacks.com/extending-meteor-accounts.html
  • 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
  • setup
    • rememberMe.config.days = 9999
    • rememberMe.config.storageClient = localStorage

NOTE: this is related to Meteor Accounts autologin pattern?

Recommendations?

like image 744
zeroasterisk Avatar asked Sep 12 '14 01:09

zeroasterisk


2 Answers

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

like image 132
Green Avatar answered Oct 19 '22 19:10

Green


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.

like image 3
Mart Avatar answered Oct 19 '22 19:10

Mart