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 { try {
const current = sessionStorage.getItem("currentuser") || users.currentuser; const current = sessionStorage.getItem("currentuser") || users.currentuser;
console.log(users.users, current); console.log(users.users, current);
if (!users.users[current]) {
window.location.href = "/login";
}
thisUser = new Localuser(users.users[current]); thisUser = new Localuser(users.users[current]);
thisUser.initwebsocket().then(() => { thisUser.initwebsocket().then(() => {
thisUser.loaduser(); thisUser.loaduser();

View file

@ -1702,9 +1702,16 @@ class Localuser {
{ {
const deleteAccount = settings.addButton(I18n.localuser.deleteAccount()).addForm( const deleteAccount = settings.addButton(I18n.localuser.deleteAccount()).addForm(
"", "",
() => { (e) => {
this.userinfo.remove(); console.log(e);
window.location.href = "/"; 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, headers: this.headers,
@ -1718,7 +1725,7 @@ class Localuser {
I18n.localuser.areYouSureDelete(I18n.localuser.sillyDeleteConfirmPhrase()), I18n.localuser.areYouSureDelete(I18n.localuser.sillyDeleteConfirmPhrase()),
"shrek", "shrek",
); );
deleteAccount.addTextInput(I18n.localuser["password:"](), "password"); const password = deleteAccount.addTextInput(I18n.localuser["password:"](), "password");
deleteAccount.addPreprocessor((obj) => { deleteAccount.addPreprocessor((obj) => {
if ("shrek" in obj) { if ("shrek" in obj) {
if (obj.shrek !== I18n.localuser.sillyDeleteConfirmPhrase()) { 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. //this currently does not work, and need to be implemented better at some time.
if (!localStorage.getItem("SWMode")) { if (!localStorage.getItem("SWMode")) {
localStorage.setItem("SWMode", "true"); localStorage.setItem("SWMode", "SWOn");
} }
trimswitcher(); trimswitcher();

View file

@ -92,6 +92,17 @@ export class Specialuser {
remove() { remove() {
const info = getBulkInfo(); const info = getBulkInfo();
delete info.users[this.uid]; 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)); localStorage.setItem("userinfos", JSON.stringify(info));
} }
set pfpsrc(e) { set pfpsrc(e) {