Created
June 14, 2018 09:23
-
-
Save m00zi/684270387bad8ee22e24213ed0fdef63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.deleteUser = (req, res, next) => { | |
var response; | |
console.log(req.params.user_id); | |
if (!req.params.user_id) { | |
response = {success: false, message: 'user id must be provided'}; | |
res.send(response); | |
return; | |
} | |
console.log(req.params.user_id); | |
User.findByIdAndRemove(req.params.user_id, (err, user) => { | |
if (err) { | |
response = {success: false, message: 'Somthing went wrong'} | |
res.send(response); | |
return; | |
} else { | |
if (user) { | |
logger.info(`User ${user._id} , ${user.email} has been deleted from database`); | |
res.send({success: true}); | |
return; | |
} else { | |
logger.info(`Something went wrong, when deleting user ${user._id} ${user.email}`); | |
res.send({success: false}); | |
return; | |
}; | |
}; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment