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