mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-13 17:52:22 +00:00
feat(premium): disallow deleting accounts until they've cancelled
payment plans
This commit is contained in:
parent
ffa21ca1f7
commit
56ab7384cf
2 changed files with 4 additions and 4 deletions
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue