feat(webui): rename account
This commit is contained in:
parent
ba7da656a8
commit
aa87ab87dd
13
src/controllers/custom/renameAccountController.ts
Normal file
13
src/controllers/custom/renameAccountController.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { RequestHandler } from "express";
|
||||||
|
import { getAccountForRequest } from "@/src/services/loginService";
|
||||||
|
|
||||||
|
export const renameAccountController: RequestHandler = async (req, res) => {
|
||||||
|
const account = await getAccountForRequest(req);
|
||||||
|
if (typeof req.query.newname == "string") {
|
||||||
|
account.DisplayName = req.query.newname;
|
||||||
|
await account.save();
|
||||||
|
res.end();
|
||||||
|
} else {
|
||||||
|
res.status(400).end();
|
||||||
|
}
|
||||||
|
};
|
@ -5,6 +5,7 @@ import { getItemListsController } from "@/src/controllers/custom/getItemListsCon
|
|||||||
import { pushArchonCrystalUpgradeController } from "@/src/controllers/custom/pushArchonCrystalUpgradeController";
|
import { pushArchonCrystalUpgradeController } from "@/src/controllers/custom/pushArchonCrystalUpgradeController";
|
||||||
import { popArchonCrystalUpgradeController } from "@/src/controllers/custom/popArchonCrystalUpgradeController";
|
import { popArchonCrystalUpgradeController } from "@/src/controllers/custom/popArchonCrystalUpgradeController";
|
||||||
import { deleteAccountController } from "@/src/controllers/custom/deleteAccountController";
|
import { deleteAccountController } from "@/src/controllers/custom/deleteAccountController";
|
||||||
|
import { renameAccountController } from "@/src/controllers/custom/renameAccountController";
|
||||||
|
|
||||||
import { createAccountController } from "@/src/controllers/custom/createAccountController";
|
import { createAccountController } from "@/src/controllers/custom/createAccountController";
|
||||||
import { addItemController } from "@/src/controllers/custom/addItemController";
|
import { addItemController } from "@/src/controllers/custom/addItemController";
|
||||||
@ -19,6 +20,7 @@ customRouter.get("/getItemLists", getItemListsController);
|
|||||||
customRouter.get("/pushArchonCrystalUpgrade", pushArchonCrystalUpgradeController);
|
customRouter.get("/pushArchonCrystalUpgrade", pushArchonCrystalUpgradeController);
|
||||||
customRouter.get("/popArchonCrystalUpgrade", popArchonCrystalUpgradeController);
|
customRouter.get("/popArchonCrystalUpgrade", popArchonCrystalUpgradeController);
|
||||||
customRouter.get("/deleteAccount", deleteAccountController);
|
customRouter.get("/deleteAccount", deleteAccountController);
|
||||||
|
customRouter.get("/renameAccount", renameAccountController);
|
||||||
|
|
||||||
customRouter.post("/createAccount", createAccountController);
|
customRouter.post("/createAccount", createAccountController);
|
||||||
customRouter.post("/addItem", addItemController);
|
customRouter.post("/addItem", addItemController);
|
||||||
|
@ -39,7 +39,8 @@
|
|||||||
<ul class="dropdown-menu dropdown-menu-end">
|
<ul class="dropdown-menu dropdown-menu-end">
|
||||||
<li><a class="dropdown-item" href="/webui/" onclick="logout();">Logout</a></li>
|
<li><a class="dropdown-item" href="/webui/" onclick="logout();">Logout</a></li>
|
||||||
<li><hr class="dropdown-divider"></li>
|
<li><hr class="dropdown-divider"></li>
|
||||||
<li><a class="dropdown-item" onclick="deleteAccount();">Delete Account</a></li>
|
<li><a class="dropdown-item" href="#" onclick="event.preventDefault();renameAccount();">Rename Account</a></li>
|
||||||
|
<li><a class="dropdown-item" href="#" onclick="event.preventDefault();deleteAccount();">Delete Account</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -61,6 +61,15 @@ function logout() {
|
|||||||
localStorage.removeItem("password");
|
localStorage.removeItem("password");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renameAccount() {
|
||||||
|
const newname = window.prompt("What would you like to change your account name to?");
|
||||||
|
if (newname) {
|
||||||
|
fetch("/custom/renameAccount?" + window.authz + "&newname=" + newname).then(() => {
|
||||||
|
$(".displayname").text(newname);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function deleteAccount() {
|
function deleteAccount() {
|
||||||
if (
|
if (
|
||||||
window.confirm(
|
window.confirm(
|
||||||
@ -71,7 +80,7 @@ function deleteAccount() {
|
|||||||
")? This action cannot be undone."
|
")? This action cannot be undone."
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
fetch("/custom/deleteAccount?" + window.authz).then(function () {
|
fetch("/custom/deleteAccount?" + window.authz).then(() => {
|
||||||
logout();
|
logout();
|
||||||
single.loadRoute("/webui/"); // Show login screen
|
single.loadRoute("/webui/"); // Show login screen
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user