meteor-user-status
meteor-user-status copied to clipboard
How to delete/remove user if he last logged in 'x' days ago?
I did something like this. The error: Exception in setInterval callback: TypeError: undefined is not a function
var days = 1;
Meteor.setInterval(function() {
var days_ago = new Date(new Date.getTime() - (360000 * 24 * days))
Meteor.users.find({'status.lastLogin.date': {$lte: days_ago}}).forEach(function(user) {
Meteor.users.remove({_id: user._id}, true);
});
}, (360000 * 24 * 1));
Meteor does something similar by pruning stale login tokens from the database, search for _expireTokens
in the following:
https://github.com/meteor/meteor/blob/devel/packages/accounts-base/accounts_server.js#L1044
I used javascript to solve this problem. Running the script after every 'y' hours, and deleting the users as required. But if meteor has something inbuilt, then I'll surely look into it
Thanks
That built-in function is not doing the same thing; I just pointed to it as an example that was doing something similar.