diff --git a/backend/open_webui/routers/openai.py b/backend/open_webui/routers/openai.py index 522861329..5ea3895b2 100644 --- a/backend/open_webui/routers/openai.py +++ b/backend/open_webui/routers/openai.py @@ -187,8 +187,15 @@ async def get_allowed_model_ids( log.warning( f"list_endpoints request error: {response.status} {list_endpoints_url}" ) + if response.status == 401: + raise HTTPException( + status_code=401, + detail="list_endpoints_unauthorized", + ) return [] data = json.loads(await response.text()) + except HTTPException: + raise except Exception as e: log.warning(f"list_endpoints fetch error: {e}") return [] diff --git a/backend/open_webui/utils/oauth.py b/backend/open_webui/utils/oauth.py index 86fa38b72..051f746f0 100644 --- a/backend/open_webui/utils/oauth.py +++ b/backend/open_webui/utils/oauth.py @@ -1429,6 +1429,7 @@ async def handle_login(self, request, provider): # [ADDITION BEGINS] Add extra parameters for Globus to include the policy if provider == "globus" and GLOBUS_HIGH_ASSURANCE_POLICY.value: kwargs["session_required_policies"] = GLOBUS_HIGH_ASSURANCE_POLICY.value + kwargs["prompt"] = "login" # [ADDITION ENDS] return await client.authorize_redirect(request, redirect_uri, **kwargs) diff --git a/src/lib/apis/index.ts b/src/lib/apis/index.ts index 8f35fbf88..d90b03741 100644 --- a/src/lib/apis/index.ts +++ b/src/lib/apis/index.ts @@ -26,7 +26,16 @@ export const getModels = async ( } ) .then(async (res) => { - if (!res.ok) throw await res.json(); + // [MODIFICATION BEGINS] + // Original: if (!res.ok) throw await res.json(); + // This adds res.status to the error object + // This allows the frontend to know when the user should be redirected + // to the logout URL (when the Globus token expires or loses the session) + if (!res.ok) { + const body = await res.json(); + throw { ...body, status: res.status }; + } + // [MODIFICATION ENDS] return res.json(); }) .catch((err) => { diff --git a/src/lib/components/common/ConfirmDialog.svelte b/src/lib/components/common/ConfirmDialog.svelte index c2273c992..a1216cb04 100644 --- a/src/lib/components/common/ConfirmDialog.svelte +++ b/src/lib/components/common/ConfirmDialog.svelte @@ -16,6 +16,9 @@ export let cancelLabel = $i18n.t('Cancel'); export let confirmLabel = $i18n.t('Confirm'); + // [ADDITION BEGINS] - Add cancel button + export let showCancel = true; + // [ADDITION ENDS] export let onConfirm = () => {}; @@ -39,7 +42,10 @@ }; const handleKeyDown = (event: KeyboardEvent) => { - if (event.key === 'Escape') { + // [MODIFICATION BEGINS] - Add cancel button + // Oritinal: if (event.key === 'Escape') { + if (event.key === 'Escape' && showCancel) { + // [MODIFICATION ENDS] console.log('Escape'); show = false; } @@ -98,7 +104,10 @@ class=" fixed top-0 right-0 left-0 bottom-0 bg-black/60 w-full h-screen max-h-[100dvh] flex justify-center z-99999999 overflow-hidden overscroll-contain" in:fade={{ duration: 10 }} on:mousedown={() => { - show = false; + // [MODIFICATION BEGINS] - Add cancel button + // Oritinal: if (showCancel) show = false; + if (showCancel) show = false; + // [MODIFICATION ENDS] }} >
-
- - + + {/if} + +