add: user is_deactivated

This commit is contained in:
trisua 2025-07-19 03:17:21 -04:00
parent 9ccbc69405
commit 63d3c2350d
13 changed files with 243 additions and 30 deletions

View file

@ -284,29 +284,50 @@
("ui_ident" "delete_account")
(div
("class" "card small flex items-center gap-2 red")
(text "{{ icon \"skull\" }}")
(b
(text "{{ text \"settings:label.delete_account\" }}")))
(form
("class" "card flex flex-col gap-2")
("onsubmit" "delete_account(event)")
(div
("class" "flex flex-col gap-1")
(label
("for" "current_password")
(text "{{ text \"settings:label.current_password\" }}"))
(input
("type" "password")
("name" "current_password")
("id" "current_password")
("placeholder" "current_password")
("required" "")
("minlength" "6")
("autocomplete" "off")))
(button
(text "{{ icon \"trash\" }}")
(span
(text "{{ text \"general:action.delete\" }}")))))
(icon (text "skull"))
(b (str (text "communities:label.danger_zone"))))
(div
("class" "card lowered flex flex-col gap-2")
(details
("class" "accordion")
(summary
("class" "flex items-center gap-2")
(icon_class (text "chevron-down") (text "dropdown_arrow"))
(str (text "settings:label.deactivate_account")))
(div
("class" "inner flex flex-col gap-2")
(p (text "Deactivating your account will treat it as deleted, but all your data will be recoverable if you change your mind. This option is recommended over a full deletion."))
(button
("onclick" "deactivate_account()")
(icon (text "lock"))
(span
(str (text "settings:label.deactivate"))))))
(details
("class" "accordion")
(summary
("class" "flex items-center gap-2")
(icon_class (text "chevron-down") (text "dropdown_arrow"))
(str (text "settings:label.delete_account")))
(form
("class" "inner flex flex-col gap-2")
("onsubmit" "delete_account(event)")
(div
("class" "flex flex-col gap-1")
(label
("for" "current_password")
(text "{{ text \"settings:label.current_password\" }}"))
(input
("type" "password")
("name" "current_password")
("id" "current_password")
("placeholder" "current_password")
("required" "")
("minlength" "6")
("autocomplete" "off")))
(button
(text "{{ icon \"trash\" }}")
(span
(text "{{ text \"general:action.delete\" }}")))))))
(button
("onclick" "save_settings()")
("id" "save_button")
@ -1612,6 +1633,31 @@
});
}
globalThis.deactivate_account = async () => {
if (
!(await trigger(\"atto::confirm\", [
\"Are you sure you want to do this?\",
]))
) {
return;
}
fetch(\"/api/v1/auth/user/{{ profile.id }}/deactivate\", {
method: \"POST\",
headers: {
\"Content-Type\": \"application/json\",
},
body: JSON.stringify({ is_deactivated: true }),
})
.then((res) => res.json())
.then((res) => {
trigger(\"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
]);
});
};
// presets
globalThis.apply_preset = async (preset) => {
if (