various bug fixes

This commit is contained in:
MathMan05 2025-03-13 20:42:21 -05:00
parent 739ee81002
commit d0d6ff8448
4 changed files with 26 additions and 5 deletions

View file

@ -110,6 +110,9 @@ import {I18n} from "./i18n.js";
try {
const current = sessionStorage.getItem("currentuser") || users.currentuser;
console.log(users.users, current);
if (!users.users[current]) {
window.location.href = "/login";
}
thisUser = new Localuser(users.users[current]);
thisUser.initwebsocket().then(() => {
thisUser.loaduser();

View file

@ -1702,9 +1702,16 @@ class Localuser {
{
const deleteAccount = settings.addButton(I18n.localuser.deleteAccount()).addForm(
"",
() => {
this.userinfo.remove();
window.location.href = "/";
(e) => {
console.log(e);
if ("message" in e) {
if (typeof e.message === "string") {
throw new FormError(password, e.message);
}
} else {
this.userinfo.remove();
window.location.href = "/";
}
},
{
headers: this.headers,
@ -1718,7 +1725,7 @@ class Localuser {
I18n.localuser.areYouSureDelete(I18n.localuser.sillyDeleteConfirmPhrase()),
"shrek",
);
deleteAccount.addTextInput(I18n.localuser["password:"](), "password");
const password = deleteAccount.addTextInput(I18n.localuser["password:"](), "password");
deleteAccount.addPreprocessor((obj) => {
if ("shrek" in obj) {
if (obj.shrek !== I18n.localuser.sillyDeleteConfirmPhrase()) {

View file

@ -223,7 +223,7 @@ if (document.getElementById("form")) {
}
//this currently does not work, and need to be implemented better at some time.
if (!localStorage.getItem("SWMode")) {
localStorage.setItem("SWMode", "true");
localStorage.setItem("SWMode", "SWOn");
}
trimswitcher();

View file

@ -92,6 +92,17 @@ export class Specialuser {
remove() {
const info = getBulkInfo();
delete info.users[this.uid];
if (info.currentuser === this.uid) {
const user = info.users[0];
if (user) {
info.currentuser = new Specialuser(user).uid;
} else {
info.currentuser = null;
}
}
if (sessionStorage.getItem("currentuser") === this.uid) {
sessionStorage.delete("currentuser");
}
localStorage.setItem("userinfos", JSON.stringify(info));
}
set pfpsrc(e) {