How to remove logged in user in Meteor


Hello everyone!
I’m developing an app in Meteor and I want to know how I do can delete a user’s account who is logged into the system? I mean that you can delete your account (like Tinder or Facebook) and the application ejects you because you’re already deleted, and you no longer exist.

With a simple button of “Delete your account” attached.

If you could help me; I’m still a novice I’d really appreciate it, I try to retrieve the id of the current user with Meteor.userId(), and I was creating a method in the following way:
SuprimirPersona: function(id) {
var postId = Meteor.userId();
console.log("id users ",id);
Meteor.users.remove({ postId: id })


And calling the method in the following way but it does not give any results, I do not understand why:

‘click #Desactivarr’: function() {
var postId = Meteor.userId();‘SuprimirPersona’, postId, function(error, result) {
if (error) {
console.log(“Somee Error”,error);
Meteor.logout(function() {
Hope someone could help me! Regards!


In your .method(), you could just use this.userId to get the ID of the current user. (so you don’t need to sent it in your .call() .

“Don’t pass userId from the client” :


You’re asking it to remove users by postId which I don’t think you’re actually trying to do, did you meant Meteor.users.remove({_id: id}) ?

The way you’re calling it seems to me that postId = Meteor.userId(), which states that:

postId = Meteor.userId() 
postId === Meteor.user()._id
// Property is _id, not postId

So you’re asking Users to remove all users that have User.postId === idPassedOnMethod
Which means no user is deleted because no user has User.postId property. You meant Meteor.users.remove({_id: id})

PostId seems to be another collection’s property.