#27 Users can delete accounts
parent
cf7dfc2b6a
commit
8949bddd95
|
@ -18,7 +18,8 @@ $ npm start
|
|||
|
||||
#### v0.4.1
|
||||
|
||||
* added linked accounts to admin
|
||||
* Users can view/change email address
|
||||
* Added linked accounts to admin
|
||||
|
||||
#### v0.4.0
|
||||
|
||||
|
|
|
@ -76,6 +76,16 @@ router.post('/:slug?', mw.ensureAuth, function(req,res,next){
|
|||
});
|
||||
});
|
||||
|
||||
router.delete('/:slug?', mw.ensureAuth, function(req,res,next){
|
||||
// Delete user account
|
||||
User.findByIdAndRemove(
|
||||
req.session.passport.user,
|
||||
function(err) {
|
||||
if (err) { console.log('Error deleting user:',err); mw.throwErr(req,err); }
|
||||
else { req.flash('success', 'Your account has been deleted. '); }
|
||||
res.redirect('/');
|
||||
}
|
||||
)
|
||||
|
||||
// Redirect /id/ to /slug/
|
||||
router.get('/id/:id', function(req,res,next){
|
||||
|
|
|
@ -122,6 +122,7 @@
|
|||
<div class='close'>
|
||||
<a href="#" title="close"><i class='fa fa-times'></i></a>
|
||||
</div>
|
||||
|
||||
<h2>Settings</h2>
|
||||
<script src="/static/js/validator.min.js"></script>
|
||||
<form id='settings-form' class='col-lg-10 col-lg-offset-1 form-horizontal' data-toggle="validator" role="form" method="post">
|
||||
|
@ -221,6 +222,10 @@
|
|||
<input class='form-control' name="showStreet" type="checkbox" {% if not user.isPro %}disabled{% elif user.settings.showStreetview %}checked{% else %}{% endif %}><br>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id='delete' class='form-group col-xs-12'>
|
||||
<button class='btn' style='width:20%;float:right;' onclick="deleteAccount()"></button>
|
||||
</div>
|
||||
|
||||
<div id='submit' class='form-group col-xs-12 flexbox' style="padding:0 0 60px">
|
||||
<input class='btn yellow' style="width:50%;" type="submit" value="Save">
|
||||
|
@ -337,6 +342,7 @@
|
|||
$('#notset').hide();
|
||||
}
|
||||
}
|
||||
|
||||
// execute on page load
|
||||
$(function() {
|
||||
toggleMaps(last);
|
||||
|
@ -542,6 +548,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
// Delete account
|
||||
function deleteAccount() {
|
||||
if (confirm("Are you sure you want to delete your account? This CANNOT be undone! ")) {
|
||||
$.ajax({
|
||||
url: "/",
|
||||
type: "DELETE",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
{% endif %}
|
||||
|
||||
// Check altitude
|
||||
|
|
Loading…
Reference in New Issue