Delete input tokens for meteor shower

I'm not sure if this was set before, but loginTokens are really big and without any cleanup they are increasing the size of my database. What is being done about this? what others do to handle it. By default, I mean Meteor.users.services , which has an array of loginTokens that are created every time a user logs in / out

 "resume" : { "loginTokens" : [ { "token" : "HMntXepqzPBLDGkGX", "when" : 1372559065392 }, { "token" : "uCHqA95HZZyN5tRtH", "when" : 1372563545565 }, { "token" : "sNGZhhATTrTg8582w", "when" : 1372622561176 }, { "token" : "hPWpm4uQQXWrkK6NS", "when" : 1372634411432 }, { "token" : "DFntTEcsKKT6bJ3rx", "when" : 1372635411745 }, { "token" : "BBM3acLQhuNtsHvkn", "when" : 1372638979158 }, { "token" : "EHgLLHMh6JWxKfuoe", "when" : 1372825386462 } ] } 
+4
source share
2 answers

This has been mentioned repeatedly in the Meteor google group, but this is not a high priority issue. In my authentication system, I delete tokens more than one day when a user logs in. This ensures that tokens do not expire if they are unable to log in for some time.

 Accounts.registerLoginHandler (loginRequest) -> # ... Do whatever you need to do to authenticate the user stampedToken = Accounts._generateStampedLoginToken(); Meteor.users.update userId, $push: {'services.resume.loginTokens': stampedToken} # Delete old resume tokens so they don't clog up the db cutoff = +(new Date) - (24*60*60)*1000 Meteor.users.update userId, { $pull: 'services.resume.loginTokens': when: {$lt: cutoff} }, {multi : true} return { id: userId, token: stampedToken.token } 
+3
source

FYI, I made a mistake on this, and there is a pending pull request that fixes it:

https://github.com/meteor/meteor/issues/891

+2
source

Source: https://habr.com/ru/post/1489584/


All Articles