feat: Allow self-service deactivation to be disabled

This commit is contained in:
Ginger
2026-05-06 14:48:07 -04:00
parent 5ca1341bf7
commit 66aba9d5d0
6 changed files with 42 additions and 1 deletions
+4 -1
View File
@@ -30,6 +30,7 @@ template! {
#[derive(Debug)]
#[allow(clippy::large_enum_variant)]
enum DeactivateBody {
Unavailable,
Form {
user_id: OwnedUserId,
user_card: UserCard,
@@ -67,7 +68,9 @@ async fn route_deactivate(
let user_card = UserCard::for_local_user(&services, user_id.clone()).await;
let body = {
if let Some(form) = form {
if !services.config.allow_deactivation {
DeactivateBody::Unavailable
} else if let Some(form) = form {
if let Err(err) = validate_deactivate_form(&services, &user_id, form).await {
DeactivateBody::Form {
user_id,
@@ -5,9 +5,18 @@ Deactivate your account
{%- endblock -%}
{%- block content -%}
{% match body %}
{% when DeactivateBody::Form { .. } | DeactivateBody::Success %}
<div class="panel">
{% when DeactivateBody::Unavailable %}
<div class="panel middle"/>
{% endmatch %}
<h1>Deactivate your account <a class="back" href="{{ crate::ROUTE_PREFIX }}/account/">Back</a></h1>
{% match body %}
{% when DeactivateBody::Unavailable %}
<p>
To deactivate your account, contact your homeserver's administrator.
</p>
{% when DeactivateBody::Form { user_id, user_card, form } %}
{{ user_card }}
<p>