move "become superuser" action into the debug menu

This commit is contained in:
hippoz 2022-09-03 17:40:54 +03:00
parent 4c9e321167
commit 5ea8cc62cd
No known key found for this signature in database
GPG key ID: 7C52899193467641

View file

@ -8,6 +8,15 @@
export let close = () => {};
const doSuperuserPrompt = async () => {
const { ok } = await request("POST", apiRoute("users/self/promote"), true);
if (ok) {
overlayStore.toast("You have been promoted to superuser");
} else {
overlayStore.toast("Failed to promote to superuser");
}
};
const doDeveloper = () => {
overlayStore.push(OverlayType.Prompt, {
heading: "",
@ -26,6 +35,9 @@
case "storage.getItem": {
return respond(getItem(parts[1]));
}
case "_actions.becomeSuperuser": {
return doSuperuserPrompt();
}
default: {
return respond("Error: unknown operator");
}
@ -39,15 +51,6 @@
logOut();
overlayStore.toast("Logged out");
};
const doSuperuserPrompt = async () => {
const { ok } = await request("POST", apiRoute("users/self/promote"), true);
if (ok) {
overlayStore.toast("You have been promoted to superuser");
} else {
overlayStore.toast("Failed to promote to superuser");
}
};
</script>
<style>
@ -99,7 +102,6 @@
<AtSignIcon />
<span class="h5 top-bar-heading">{ $userInfoStore ? $userInfoStore.username : "" }</span>
<div class="account-buttons">
<button class="button button-red" on:click="{ doSuperuserPrompt }">Become Superuser</button>
<button class="button button-red" on:click="{ doLogout }">Log Out</button>
</div>
</div>