add account deletion
This commit is contained in:
parent
1a59dfbd34
commit
739ee81002
5 changed files with 46 additions and 8 deletions
|
@ -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();
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue