Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to delete/remove user if he last logged in 'x' days ago? #65

Open
chauhanshubham-dev opened this issue Jun 1, 2015 · 3 comments
Open
Labels

Comments

@chauhanshubham-dev
Copy link

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));

@chauhanshubham-dev chauhanshubham-dev changed the title How to delete/remove user if he last logged in 'x' months ago? How to delete/remove user if he last logged in 'x' days ago? Jun 1, 2015
@mizzao
Copy link
Collaborator

mizzao commented Jul 9, 2015

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

@mizzao mizzao added the question label Jul 9, 2015
@chauhanshubham-dev
Copy link
Author

chauhanshubham-dev commented Jul 9, 2015 via email

@mizzao
Copy link
Collaborator

mizzao commented Jul 9, 2015

That built-in function is not doing the same thing; I just pointed to it as an example that was doing something similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants