Revert "Implement admin back-pass flow and guarded admin actions"
This reverts commit 5595bfd3b1.
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
import { api } from "./api.js";
|
||||
import { t } from "./i18n.js";
|
||||
import {
|
||||
state,
|
||||
clearUserState,
|
||||
clearSavedUsername,
|
||||
setSavedUsername,
|
||||
} from "./state.js";
|
||||
import { state, clearUserState, setSavedUsername } from "./state.js";
|
||||
import { $, toast } from "./dom.js";
|
||||
import {
|
||||
handleAuthError,
|
||||
@@ -144,38 +139,24 @@ function setupLogoutHandler() {
|
||||
const logoutBtn = $("logout");
|
||||
if (!logoutBtn) return;
|
||||
|
||||
const clearAuthFormFields = () => {
|
||||
[
|
||||
"login-username",
|
||||
"login-password",
|
||||
"register-username",
|
||||
"register-password",
|
||||
"register-displayName",
|
||||
"register-adminkey",
|
||||
].forEach((id) => {
|
||||
const input = $(id);
|
||||
if (input) input.value = "";
|
||||
});
|
||||
|
||||
["login-consent", "register-consent"].forEach((id) => {
|
||||
const box = $(id);
|
||||
if (box) box.checked = false;
|
||||
});
|
||||
};
|
||||
|
||||
logoutBtn.addEventListener("click", async (e) => {
|
||||
e.preventDefault();
|
||||
const lastUser = state.me?.username;
|
||||
try {
|
||||
await api.logout();
|
||||
} catch (err) {
|
||||
toast(err.message, true);
|
||||
}
|
||||
clearUserState();
|
||||
clearSavedUsername();
|
||||
state.isAuthenticated = false;
|
||||
setAuthMode("login");
|
||||
setAuthUI(false);
|
||||
clearAuthFormFields();
|
||||
if (lastUser) {
|
||||
setSavedUsername(lastUser);
|
||||
const loginUser = $("login-username");
|
||||
if (loginUser) loginUser.value = lastUser;
|
||||
const loginPass = $("login-password");
|
||||
if (loginPass) loginPass.value = "";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user