add account deletion

This commit is contained in:
MathMan05 2025-03-13 19:56:55 -05:00
parent 1a59dfbd34
commit 739ee81002
5 changed files with 46 additions and 8 deletions

View file

@ -1699,6 +1699,37 @@ class Localuser {
devPortal.addHTMLArea(appListContainer);
});
}
{
const deleteAccount = settings.addButton(I18n.localuser.deleteAccount()).addForm(
"",
() => {
this.userinfo.remove();
window.location.href = "/";
},
{
headers: this.headers,
method: "POST",
fetchURL: this.info.api + "/users/@me/delete/",
traditionalSubmit: false,
submitText: I18n.localuser.deleteAccountButton(),
},
);
const shrek = deleteAccount.addTextInput(
I18n.localuser.areYouSureDelete(I18n.localuser.sillyDeleteConfirmPhrase()),
"shrek",
);
deleteAccount.addTextInput(I18n.localuser["password:"](), "password");
deleteAccount.addPreprocessor((obj) => {
if ("shrek" in obj) {
if (obj.shrek !== I18n.localuser.sillyDeleteConfirmPhrase()) {
throw new FormError(shrek, I18n.localuser.mustTypePhrase());
}
delete obj.shrek;
} else {
throw new FormError(shrek, I18n.localuser.mustTypePhrase());
}
});
}
settings.show();
}
readonly botTokens: Map<string, string> = new Map();

View file

@ -790,7 +790,7 @@ class Options implements OptionsElement<void> {
onSubmit: (arg1: object, sent: object) => void,
{
ltr = false,
submitText = "Submit",
submitText = I18n.getTranslation("submit"),
fetchURL = "",
headers = {},
method = "POST",

View file

@ -89,6 +89,11 @@ export class Specialuser {
console.error("There are fundamentally missing pieces of info missing from this user");
}
}
remove() {
const info = getBulkInfo();
delete info.users[this.uid];
localStorage.setItem("userinfos", JSON.stringify(info));
}
set pfpsrc(e) {
this.json.pfpsrc = e;
this.updateLocal();