mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
feat: Allow self-service deactivation to be disabled
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
Users may now be forbidden from deactivating their own accounts with the new `allow_deactivation` config option.
|
||||||
@@ -521,6 +521,16 @@
|
|||||||
#
|
#
|
||||||
#recaptcha_private_site_key =
|
#recaptcha_private_site_key =
|
||||||
|
|
||||||
|
# Controls whether users are allowed to deactivate their own accounts
|
||||||
|
# through the account management panel or their Matrix clients. Server
|
||||||
|
# admins can always deactivate users using the relevant admin commands.
|
||||||
|
#
|
||||||
|
# Note that, in some jurisdictions, you may be legally required to honor
|
||||||
|
# users who request to deactivate their accounts if you set this option
|
||||||
|
# to `false`.
|
||||||
|
#
|
||||||
|
#allow_deactivation = true
|
||||||
|
|
||||||
# Controls whether encrypted rooms and events are allowed.
|
# Controls whether encrypted rooms and events are allowed.
|
||||||
#
|
#
|
||||||
#allow_encryption = true
|
#allow_encryption = true
|
||||||
|
|||||||
@@ -283,6 +283,13 @@ pub(crate) async fn deactivate_route(
|
|||||||
|
|
||||||
let sender_user = identity.sender_user();
|
let sender_user = identity.sender_user();
|
||||||
|
|
||||||
|
if !services.config.allow_deactivation {
|
||||||
|
return Err!(Request(Unauthorized(
|
||||||
|
"You may not deactivate your own account. Contact your server's administrator for \
|
||||||
|
assistance."
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
// Prompt the user to confirm with their password using UIAA
|
// Prompt the user to confirm with their password using UIAA
|
||||||
let _ = services
|
let _ = services
|
||||||
.uiaa
|
.uiaa
|
||||||
|
|||||||
@@ -663,6 +663,17 @@ pub struct Config {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub oauth: OauthConfig,
|
pub oauth: OauthConfig,
|
||||||
|
|
||||||
|
/// Controls whether users are allowed to deactivate their own accounts
|
||||||
|
/// through the account management panel or their Matrix clients. Server
|
||||||
|
/// admins can always deactivate users using the relevant admin commands.
|
||||||
|
///
|
||||||
|
/// Note that, in some jurisdictions, you may be legally required to honor
|
||||||
|
/// users who request to deactivate their accounts if you set this option
|
||||||
|
/// to `false`.
|
||||||
|
///
|
||||||
|
/// default: true
|
||||||
|
pub allow_deactivation: bool,
|
||||||
|
|
||||||
/// Controls whether encrypted rooms and events are allowed.
|
/// Controls whether encrypted rooms and events are allowed.
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
pub allow_encryption: bool,
|
pub allow_encryption: bool,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ template! {
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
enum DeactivateBody {
|
enum DeactivateBody {
|
||||||
|
Unavailable,
|
||||||
Form {
|
Form {
|
||||||
user_id: OwnedUserId,
|
user_id: OwnedUserId,
|
||||||
user_card: UserCard,
|
user_card: UserCard,
|
||||||
@@ -67,7 +68,9 @@ async fn route_deactivate(
|
|||||||
let user_card = UserCard::for_local_user(&services, user_id.clone()).await;
|
let user_card = UserCard::for_local_user(&services, user_id.clone()).await;
|
||||||
|
|
||||||
let body = {
|
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 {
|
if let Err(err) = validate_deactivate_form(&services, &user_id, form).await {
|
||||||
DeactivateBody::Form {
|
DeactivateBody::Form {
|
||||||
user_id,
|
user_id,
|
||||||
|
|||||||
@@ -5,9 +5,18 @@ Deactivate your account
|
|||||||
{%- endblock -%}
|
{%- endblock -%}
|
||||||
|
|
||||||
{%- block content -%}
|
{%- block content -%}
|
||||||
|
{% match body %}
|
||||||
|
{% when DeactivateBody::Form { .. } | DeactivateBody::Success %}
|
||||||
<div class="panel">
|
<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>
|
<h1>Deactivate your account <a class="back" href="{{ crate::ROUTE_PREFIX }}/account/">Back</a></h1>
|
||||||
{% match body %}
|
{% match body %}
|
||||||
|
{% when DeactivateBody::Unavailable %}
|
||||||
|
<p>
|
||||||
|
To deactivate your account, contact your homeserver's administrator.
|
||||||
|
</p>
|
||||||
{% when DeactivateBody::Form { user_id, user_card, form } %}
|
{% when DeactivateBody::Form { user_id, user_card, form } %}
|
||||||
{{ user_card }}
|
{{ user_card }}
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
Reference in New Issue
Block a user