[#1477] add delete account

This commit is contained in:
Tyler Renelle
2013-09-08 15:17:49 -04:00
parent f250a98fb7
commit 5c5212eb0e
5 changed files with 18 additions and 7 deletions

View File

@@ -1,6 +0,0 @@
appExports.deleteAccount = (e, el) ->
model.del "users.#{user.get('id')}", ->
location.href = "/logout"

View File

@@ -75,5 +75,15 @@ habitrpg.controller('SettingsCtrl',
alert(data);
});
}
$scope['delete'] = function(){
$http['delete'](API_URL + '/api/v1/user')
.success(function(){
localStorage.clear();
window.location.href = '/logout';
})
.error(function(data){
alert(data);
});
}
}
]);

View File

@@ -555,7 +555,13 @@ api.reset = function(req, res){
if (err) return res.json(500,{err:err});
res.json(saved);
})
}
api['delete'] = function(req, res) {
res.locals.user.remove(function(err){
if (err) return res.json(500,{err:err});
res.send(200);
})
}

View File

@@ -48,6 +48,7 @@ router.post('/user/batch-update', auth.auth, cron, user.batchUpdate);
router.post('/user/reroll', auth.auth, cron, user.reroll);
router.post('/user/buy-gems', auth.auth, user.buyGems);
router.post('/user/reset', auth.auth, user.reset);
router['delete']('/user', auth.auth, user['delete']);
/* Groups*/
router.get('/groups', auth.auth, groups.getGroups);

View File

@@ -55,4 +55,4 @@ div(ng-controller='SettingsCtrl')
input(type='text', ng-model='_deleteAccount')
footer
button.btn.btn-default(ng-click='modals.delete = false') Cancel
button.btn.btn-danger.btn-small(ng-disabled='_deleteAccount != "DELETE"', data-dismiss='modal', ng-click='notPorted()') Delete Account
button.btn.btn-danger.btn-small(ng-disabled='_deleteAccount != "DELETE"', ng-click='delete()') Delete Account