mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
22 lines
688 B
CoffeeScript
22 lines
688 B
CoffeeScript
User = require("../../models/User").User
|
|
NewsletterManager = require "../../managers/NewsletterManager"
|
|
ProjectDeleter = require("../Project/ProjectDeleter")
|
|
logger = require("logger-sharelatex")
|
|
|
|
module.exports =
|
|
|
|
deleteUser: (user_id, callback = ()->)->
|
|
if !user_id?
|
|
logger.err "user_id is null when trying to delete user"
|
|
return callback("no user_id")
|
|
User.findById user_id, (err, user)->
|
|
logger.log user:user, "deleting user"
|
|
if err?
|
|
return callback(err)
|
|
NewsletterManager.unsubscribe user, (err)->
|
|
if err?
|
|
return callback(err)
|
|
ProjectDeleter.deleteUsersProjects user._id, (err)->
|
|
if err?
|
|
return callback(err)
|
|
user.remove callback
|