mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 11:49:25 +00:00
Add account deletion
This commit is contained in:
@@ -12,6 +12,7 @@ const elements = {
|
||||
allowScriptChat: document.getElementById("allow-script-chat"),
|
||||
scriptSettingsStatus: document.getElementById("script-settings-status"),
|
||||
scriptSettingsSaveButton: document.getElementById("save-script-settings-btn"),
|
||||
deleteAccountButton: document.getElementById("delete-account-btn"),
|
||||
};
|
||||
|
||||
const apiBase = `/api/channels/${encodeURIComponent(broadcaster)}`;
|
||||
@@ -307,6 +308,31 @@ async function saveScriptSettings() {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteAccount() {
|
||||
const confirmation = window.prompt(
|
||||
"Type DELETE to permanently remove your account, assets, and session.",
|
||||
);
|
||||
if (confirmation !== "DELETE") {
|
||||
if (confirmation !== null) {
|
||||
showToast("Account deletion cancelled.", "info");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
setButtonBusy(elements.deleteAccountButton, true, "Deleting...");
|
||||
try {
|
||||
const response = await fetch("/api/account", { method: "DELETE" });
|
||||
if (!response.ok) {
|
||||
throw new Error("Delete account failed");
|
||||
}
|
||||
showToast("Account deleted. Redirecting...", "success");
|
||||
window.location.href = "/";
|
||||
} catch (error) {
|
||||
showToast("Unable to delete account right now. Please retry.", "error");
|
||||
setButtonBusy(elements.deleteAccountButton, false, "Deleting...");
|
||||
}
|
||||
}
|
||||
|
||||
if (elements.adminInput) {
|
||||
elements.adminInput.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Enter") {
|
||||
@@ -320,3 +346,7 @@ fetchAdmins();
|
||||
fetchSuggestedAdmins();
|
||||
fetchCanvasSettings();
|
||||
fetchScriptSettings();
|
||||
|
||||
if (elements.deleteAccountButton) {
|
||||
elements.deleteAccountButton.addEventListener("click", deleteAccount);
|
||||
}
|
||||
|
||||
@@ -161,6 +161,23 @@
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="card dashboard-span-full">
|
||||
<div class="card-header">
|
||||
<div>
|
||||
<p class="eyebrow">Account</p>
|
||||
<h3>Delete account</h3>
|
||||
<p class="muted">
|
||||
Permanently remove your account, assets, and session. This cannot be undone.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-actions">
|
||||
<button id="delete-account-btn" class="secondary danger" type="button">
|
||||
Delete my account
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/js/cookie-consent.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user