Fix: Attempt to Patch UI Login (Not-Working)

This commit is contained in:
Youwes09
2026-05-19 19:25:43 -05:00
parent 50dd8d7e35
commit b7197a09a7
2 changed files with 42 additions and 35 deletions
+7 -1
View File
@@ -276,7 +276,13 @@ export const uiAuth = {
}; };
export const authSession = { export const authSession = {
clearTokens() { uiAuth.clearToken(); }, clearTokens() {
_refreshPromise = null;
_jwtSettings = null;
_jwtSettingsBase = null;
_jwtSettingsFetchedAt = 0;
uiAuth.clearToken();
},
hasSession(): boolean { hasSession(): boolean {
const mode = store.settings.serverAuthMode ?? "NONE"; const mode = store.settings.serverAuthMode ?? "NONE";
if (mode === "UI_LOGIN") return uiAuth.getSession() !== null; if (mode === "UI_LOGIN") return uiAuth.getSession() !== null;
@@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { store, updateSettings } from "@store/state.svelte"; import { store, updateSettings } from "@store/state.svelte";
import { gql } from "@api/client"; import { gql } from "@api/client";
import { authSession, loginUI } from "@core/auth"; import { authSession, loginUI, logout } from "@core/auth";
import { GET_SERVER_SECURITY } from "@api/queries/extensions"; import { GET_SERVER_SECURITY } from "@api/queries/extensions";
import { SET_SERVER_AUTH, SET_SOCKS_PROXY, SET_FLARESOLVERR } from "@api/mutations/extensions"; import { SET_SERVER_AUTH, SET_SOCKS_PROXY, SET_FLARESOLVERR } from "@api/mutations/extensions";
@@ -44,7 +44,7 @@
} }
$effect(() => { $effect(() => {
if (!secLoaded) { secLoaded = true; loadServerSecurity(); } if (!secLoaded) { secLoaded = true; authSession.clearTokens(); loadServerSecurity(); }
}); });
async function loadServerSecurity() { async function loadServerSecurity() {
@@ -59,6 +59,7 @@
}}>(GET_SERVER_SECURITY); }}>(GET_SERVER_SECURITY);
const s = res.settings; const s = res.settings;
const serverMode = normalizeAuthMode(s.authMode); const serverMode = normalizeAuthMode(s.authMode);
if (serverMode !== "UI_LOGIN") authSession.clearTokens();
authMode = serverMode; authMode = serverMode;
authUsername = s.authUsername || ""; authUsername = s.authUsername || "";
updateSettings({ serverAuthMode: serverMode, serverAuthUser: authUsername }); updateSettings({ serverAuthMode: serverMode, serverAuthUser: authUsername });
@@ -89,11 +90,11 @@
try { try {
const newUser = authUsername.trim(); const newUser = authUsername.trim();
const newPass = authPassword.trim(); const newPass = authPassword.trim();
authSession.clearTokens();
if (authMode === "UI_LOGIN") { if (authMode === "UI_LOGIN") {
await loginUI(newUser, newPass); await loginUI(newUser, newPass);
updateSettings({ serverAuthMode: "UI_LOGIN", serverAuthUser: newUser, serverAuthPass: "" }); updateSettings({ serverAuthMode: "UI_LOGIN", serverAuthUser: newUser, serverAuthPass: "" });
} else { } else {
authSession.clearTokens();
updateSettings({ serverAuthMode: "BASIC_AUTH", serverAuthUser: newUser, serverAuthPass: newPass }); updateSettings({ serverAuthMode: "BASIC_AUTH", serverAuthUser: newUser, serverAuthPass: newPass });
} }