config: add DISABLE_ACCOUNT_DELETION

This commit is contained in:
augustin64 2024-02-28 23:59:14 +01:00
parent bfb6a127f0
commit 7ae8a1939a
4 changed files with 15 additions and 5 deletions

View File

@ -14,6 +14,9 @@ MAX_ONLINE_QUERIES=3
# Disable registration of new users via /auth/register (they can still be added by root)
DISABLE_REGISTER=False
# Disable account deletion for users (still possible for admins)
DISABLE_ACCOUNT_DELETION=False
# Front URL of the application (for QRCodes generation)
BASE_URL="http://localhost:5000"

View File

@ -50,7 +50,8 @@ def user_inspect(user_id):
"settings/index.html",
skip_old_password=True,
inspected_user=inspected_user,
user=current_user
user=current_user,
deletion_allowed=True
)

View File

@ -27,7 +27,8 @@ def index():
return render_template(
"settings/index.html",
inspected_user=user,
user=user
user=user,
deletion_allowed=not current_app.config["DISABLE_ACCOUNT_DELETION"]
)
@ -48,6 +49,10 @@ def delete_account():
if cur_user.id != mod_user.id:
flash(_("Missing rights."))
return redirect(request.referrer)
if current_app.config["DISABLE_ACCOUNT_DELETION"]:
flash(_("You are not allowed to delete your account."))
return redirect(request.referrer)
else:
log_data = [mod_user.username, mod_user.id, cur_user.username]

View File

@ -35,8 +35,9 @@
<input type="hidden" id="user_id" name="user_id" value="{{ inspected_user.id }}">
<input type="Submit" value="{{ _('confirm') }}">
</form>
<h3>{{ _("Delete account") }}</h3>
<a href="#delete-account"><button class="red-confirm">{{ _("Delete account") }}</button></a>
{% if deletion_allowed %}
<h3>{{ _("Delete account") }}</h3>
<a href="#delete-account"><button class="red-confirm">{{ _("Delete account") }}</button></a>
{% endif %}
{% endblock %}