From ed17bd026d41e942fc10416383a52746f2d2e22b Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Wed, 8 Jun 2016 15:36:08 +0100 Subject: [PATCH] added delete user script in grunt --- services/web/Gruntfile.coffee | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/services/web/Gruntfile.coffee b/services/web/Gruntfile.coffee index 428e4d506d..d069c5bac9 100644 --- a/services/web/Gruntfile.coffee +++ b/services/web/Gruntfile.coffee @@ -356,4 +356,24 @@ module.exports = (grunt) -> #{settings.siteUrl}/user/password/set?passwordResetToken=#{token} """ - done() \ No newline at end of file + done() + + grunt.registerTask 'delete-user', "deletes a user and all their data", () -> + done = @async() + email = grunt.option("email") + if !email? + console.error "Usage: grunt delete-user --email joe@example.com" + process.exit(1) + settings = require "settings-sharelatex" + UserGetter = require "./app/js/Features/User/UserGetter" + UserDeleter = require "./app/js/Features/User/UserDeleter" + UserGetter.getUser email:email, (error, user) -> + if error? + throw error + if !user? + console.log("user #{email} not in database, potentially already deleted") + return done() + UserDeleter.deleteUser user._id, (err)-> + if err? + throw err + done() \ No newline at end of file