diff --git a/view/account/delete.html b/view/account/delete.html new file mode 100644 index 00000000..032d4ce0 --- /dev/null +++ b/view/account/delete.html @@ -0,0 +1,45 @@ + + + +

Delete Account

+
+
+
+
+ Delete Account +

If you no longer wish for {{appName}} to maintain a copy of your account information or user data, you may delete using the form below.

+

Warning: Deleting your account will result in the permanent removal of any services or data you've created on hook.io

+
+ +
+
+
+ +
+ +
+
+
\ No newline at end of file diff --git a/view/account/delete.js b/view/account/delete.js new file mode 100644 index 00000000..448813c7 --- /dev/null +++ b/view/account/delete.js @@ -0,0 +1,56 @@ +var config = require('../../config'); +var email = require('resource-email'); +var psr = require('parse-service-request'); + +module['exports'] = function (opts, cb) { + var $ = this.$, + req = opts.req, + res = opts.res; + + $ = req.white($); + + var appAdminEmail = config.app.adminEmail; + + psr(req, res, function(req, res){ + + if (req.method === "POST") { + var params = req.resource.params; + + if (params.confirmDelete !== "on") { + return res.end('error: must set confirmDelete checkbox'); + } + + var cancel = { + user: req.session.user, + email: req.session.email, + reason: req.resource.params.reason, + date: new Date() + }; + + var _config = { + //provider: 'sendgrid', + provider: config.email.provider, + api_user: config.email.api_user, + api_key: config.email.api_key, + to: "marak.squires@gmail.com", + from: "accounts@hook.io", + subject: 'hook.io - delete account information', + html: JSON.stringify(cancel, true, 2) + }; + email.send(_config, function (err, result) { + if (err) { + // TODO: better errors here with /config/messages/*.js errors + return res.end('error communicating with mail provider ' + err.message); + } + $('.deleteForm').remove(); + $('.message').html('Your account deletion request is now being processed.
Please contact support if you have any additional questions.') + return cb(null, $.html()); + }); + } else { + var out = $.html(); + out = out.replace(/\{\{appAdminEmail\}\}/g, appAdminEmail); + cb(null, out); + } + }); + +}; \ No newline at end of file