feat(premium): disallow deleting accounts until they've cancelled

payment plans
This commit is contained in:
Tyler Renelle 2014-04-14 23:07:30 -06:00
parent ffa21ca1f7
commit 56ab7384cf
2 changed files with 4 additions and 4 deletions

View file

@ -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);
});
}
}

View file

@ -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);