Add user self delete function

This commit is contained in:
Stephan Porada
2019-09-10 14:18:20 +02:00
parent 2f6dd37abb
commit d537096f74
3 changed files with 38 additions and 1 deletions

View File

@ -160,3 +160,13 @@ def edit_profile():
change_profile_form=change_profile_form,
title='Edit Profile'
)
@auth.route('/edit_profile/delete_self/<int:user_id>', methods=['GET', 'POST'])
@login_required
def delete_self(user_id):
selected_user = User.query.filter_by(id=user_id).first()
db.session.delete(selected_user)
db.session.commit()
flash('Your account has been deleted!')
return redirect(url_for('main.index'))