This commit is contained in:
Timothy Jaeryang Baek
2026-07-01 01:46:36 -05:00
parent 0b0eec05f8
commit 56ee875e21

View File

@@ -810,18 +810,17 @@
});
};
const isAuthFailureResponse = async (response) => {
try {
const data = await response.clone().json();
const detail = data?.detail;
return (
detail === '401 Unauthorized' ||
detail === 'Not authenticated' ||
detail === 'Your session has expired or the token is invalid. Please sign in again.'
);
} catch {
return true;
}
const isCurrentSessionUnauthorized = async (originalFetch) => {
return originalFetch(`${WEBUI_API_BASE_URL}/auths/`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${localStorage.token}`
},
credentials: 'include'
})
.then((res) => res.status === 401)
.catch(() => false);
};
const checkTokenExpiry = async () => {
@@ -954,7 +953,7 @@
response.status === 401 &&
localStorage.token &&
isAuthenticatedBackendFetch(input, init) &&
(await isAuthFailureResponse(response))
(await isCurrentSessionUnauthorized(originalFetch))
) {
redirectToAuthAfterUnauthorized();
}