From 56ab7384cfd85ad34049f1bb41cd214135b130ad Mon Sep 17 00:00:00 2001 From: Tyler Renelle Date: Mon, 14 Apr 2014 23:07:30 -0600 Subject: [PATCH] feat(premium): disallow deleting accounts until they've cancelled payment plans --- public/js/controllers/settingsCtrl.js | 6 ++---- src/controllers/user.js | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/js/controllers/settingsCtrl.js b/public/js/controllers/settingsCtrl.js index cc82ef8875..617273253a 100644 --- a/public/js/controllers/settingsCtrl.js +++ b/public/js/controllers/settingsCtrl.js @@ -106,12 +106,10 @@ habitrpg.controller('SettingsCtrl', $scope['delete'] = function(){ $http['delete'](API_URL + '/api/v2/user') - .success(function(){ + .success(function(res, code){ + if (res.err) return alert(res.err); localStorage.clear(); window.location.href = '/logout'; - }) - .error(function(data){ - alert(data); }); } } diff --git a/src/controllers/user.js b/src/controllers/user.js index 91329c4a2b..54fa1978bd 100644 --- a/src/controllers/user.js +++ b/src/controllers/user.js @@ -260,6 +260,8 @@ api.cron = function(req, res, next) { // api.reset // Shared.ops api['delete'] = function(req, res, next) { + if (res.locals.user.purchased.plan.customerId) + return res.json(400,{err:"You have an active subscription, cancel your plan before deleting your account."}); res.locals.user.remove(function(err){ if (err) return next(err); res.send(200);