How to soft delete users


#1

Hi , I would like to add the ability to delete their accounts to my users, but for administrative purposes I would like to just make a soft delete, has anybody implemented something like this on Meteor users’ and if so what was your approach or what would you think would be the best approach. Thanks in advance!


#2

Wouldn’t be too hard, just add a field, something along the lines of “profile.removed”: false or true to the user object, then adjust the rest of your app accordingly. I can’t see a simpler method, nor the advantage of a more difficult one.


#3

Thanks, that is just what I did, I added a field to the users and then I checked against it on the after login function to check if the account ‘exists’.


#4

Just not in profile object so users cant play with it.


#5

Feel like it wouldn’t give a great experience for users that try to log in to an account they forgot they deleted. They also wouldn’t be able to recreate the account with same username/email. You would also have to keep it in mind if they’d try to use forgotten password functionality.

In my opinion it’s usually better to remove the user document from its collection and add it to another collection for deleted accounts. Keeps the Meteor.users collection lean and clean.


#6

I usually put dates for these kind of things, something like removedAt. In the end it will be a falsey value if undefined


#7

There is also a package available:

https://atmospherejs.com/zimme/collection-softremovable