From 6ef9dc8b99f17ecdf1b7c1052ae1f0d75739f319 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Sun, 18 Aug 2024 12:45:33 +0200 Subject: [PATCH] Attempt to fix or at least help debug #1028 --- common/spaces/http_space_primitives.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/common/spaces/http_space_primitives.ts b/common/spaces/http_space_primitives.ts index c0cfe95a..89d8d6be 100644 --- a/common/spaces/http_space_primitives.ts +++ b/common/spaces/http_space_primitives.ts @@ -37,23 +37,28 @@ export class HttpSpacePrimitives implements SpacePrimitives { if (result.status === 503) { throw new Error("Offline"); } + // Attempting to handle various authentication proxies if (result.redirected) { - if (result.status === 401) { + if (result.status === 401 || result.status === 403) { console.log( "Received unauthorized status and got a redirect via the API so will redirect to URL", result.url, ); - alert("You are not authenticated, redirecting to login page..."); + alert("You are not authenticated, redirecting to: " + result.url); location.href = result.url; throw new Error("Not authenticated"); } else { + alert("Received a redirect, redirecting to URL: " + result.url); location.href = result.url; throw new Error("Redirected"); } } - if (result.status === 401) { + if (result.status === 401 || result.status === 403) { + alert( + "You are not authenticated, going to reload and hope that that kicks off authentication", + ); location.reload(); - throw new Error("Not authenticated, got 403"); + throw new Error("Not authenticated, got 401"); } return result; } catch (e: any) {