master
Keith Irwin 2017-05-07 01:59:21 -04:00
parent 27af445e6f
commit e23c00f41c
No known key found for this signature in database
GPG Key ID: 378933C743E2BBC0
2 changed files with 43 additions and 54 deletions

View File

@ -166,11 +166,10 @@ router.route('/')
res.redirect('/settings');
});
} )
// Delete user account
.delete( (req,res,next)=>{
} );
// Delete account
router.get('/delete', (req,res)=>{
User.findByIdAndRemove(req.user)
.then( ()=>{
req.flash('success', 'Your account has been deleted. ');
@ -180,7 +179,6 @@ router.route('/')
mw.throwErr(err,req);
res.redirect('/settings');
});
});
// Confirm email address

View File

@ -26,16 +26,7 @@ $(function(){
// Delete account
$('#delete').click(function(){
if (confirm("Are you sure you want to delete your account? This CANNOT be undone! ")) {
$.ajax({
url: '/settings',
type: 'DELETE',
success: function(){
location.reload();
},
fail: function(){
alert("Failed to delete account!");
}
});
window.location.href = "/settings/delete";
}
});