Attempt to fix or at least help debug #1028

pull/1054/head
Zef Hemel 2024-08-18 12:45:33 +02:00
parent 9e3fe5db73
commit 6ef9dc8b99
1 changed files with 9 additions and 4 deletions

View File

@ -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) {