diff --git a/app/dashboard/templates/dashboard/setting.html b/app/dashboard/templates/dashboard/setting.html index 7da137ef..f7c3337b 100644 --- a/app/dashboard/templates/dashboard/setting.html +++ b/app/dashboard/templates/dashboard/setting.html @@ -57,7 +57,35 @@ +
+

Delete Account

+
Please note that this operation is irreversible. + +
+
+ + Delete account +
+ {% endblock %} +{% block script %} + +{% endblock %} + diff --git a/app/dashboard/views/setting.py b/app/dashboard/views/setting.py index b6379936..d73100eb 100644 --- a/app/dashboard/views/setting.py +++ b/app/dashboard/views/setting.py @@ -2,7 +2,7 @@ from io import BytesIO import arrow from flask import render_template, request, redirect, url_for, flash -from flask_login import login_required, current_user +from flask_login import login_required, current_user, logout_user from flask_wtf import FlaskForm from flask_wtf.file import FileField from wtforms import StringField, validators @@ -111,6 +111,13 @@ def setting(): elif request.form.get("form-name") == "change-password": send_reset_password_email(current_user) + elif request.form.get("form-name") == "delete-account": + User.delete(current_user.id) + db.session.commit() + flash("Your account has been deleted", "success") + logout_user() + return redirect(url_for("auth.register")) + return redirect(url_for("dashboard.setting")) return render_template(