Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you delete user accounts in Meteor?

Tags:

meteor

The only way I have found to delete user accounts in meteor (other than emptying the database with mrt reset), is by actually logging into that specific user account, and deleting the account from the console, using:

Meteor.users.remove('the user id');  

But like I said, I need to be logged in as that specific user, and have not been able to find a solution which enables me to delete any user from the db. I'm sure it has something to do with permissions or roles, but I am not sure how to proceed / what is the best solution / how to set an administrative role for a particular user, so that I can delete different user accounts.

like image 862
Eric Leroy Avatar asked Jun 10 '13 12:06

Eric Leroy


2 Answers

You could do

meteor mongo

or

meteor mongo myapp.meteor.com for a deployed app

Then

db.users.remove({_id:<user id>});

I wouldn't recommend it but if you want to delete any user without being logged in from meteor you would need to modify the allow rules. But deleting a user is a very unlikely event hence the above might be the best way to do it.

Anyway if you do want, modify the Meteor.users.allow({remove:function() { return true }); property. See http://docs.meteor.com/#allow. You could add in some custom logic there so it'll only let you do so if you're the admin

like image 200
Tarang Avatar answered Sep 26 '22 00:09

Tarang


Here are the steps to delete user from mongo through console:
step 1: open new console
step 2: change diretory to your app such as (cd myapp)
step 3 : enter command meteor mongo
step 4: make sure there exists a table called users, db.users.find({});
step 5: find the userid of the user you wish to delete and type :

db.users.remove({_id:"nRXJCC9wTx5x6wSP2"}); // id should be within quotes
like image 29
Remya CV Avatar answered Sep 27 '22 00:09

Remya CV