This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-01 01:46:36 -05:00
1 parent 0b0eec05f8
commit 56ee875e21
1 file changed
+12 -13
+12 -13
View File
@@ -810,18 +810,17 @@
}); });
}; };
const isAuthFailureResponse = async (response) => { const isCurrentSessionUnauthorized = async (originalFetch) => {
try { return originalFetch(`${WEBUI_API_BASE_URL}/auths/`, {
const data = await response.clone().json(); method: 'GET',
const detail = data?.detail; headers: {
return ( 'Content-Type': 'application/json',
detail === '401 Unauthorized' || Authorization: `Bearer ${localStorage.token}`
detail === 'Not authenticated' || },
detail === 'Your session has expired or the token is invalid. Please sign in again.' credentials: 'include'
); })
} catch { .then((res) => res.status === 401)
return true; .catch(() => false);
}
}; };
const checkTokenExpiry = async () => { const checkTokenExpiry = async () => {
@@ -954,7 +953,7 @@
response.status === 401 && response.status === 401 &&
localStorage.token && localStorage.token &&
isAuthenticatedBackendFetch(input, init) && isAuthenticatedBackendFetch(input, init) &&
(await isAuthFailureResponse(response)) (await isCurrentSessionUnauthorized(originalFetch))
) { ) {
redirectToAuthAfterUnauthorized(); redirectToAuthAfterUnauthorized();
} }