More refactoring

This commit is contained in:
Zef Hemel
2023-07-27 12:37:39 +02:00
parent 4d0f36d475
commit bfce343e7b
2 changed files with 18 additions and 7 deletions
+7 -1
View File
@@ -33,7 +33,7 @@ export class HttpSpacePrimitives implements SpacePrimitives {
result.url,
);
location.href = result.url;
throw new Error("Invalid credentials");
throw new Error("Not authenticated");
}
return result;
} catch (e: any) {
@@ -155,4 +155,10 @@ export class HttpSpacePrimitives implements SpacePrimitives {
perm: (res.headers.get("X-Permission") as "rw" | "ro") || "rw",
};
}
// Used to check if the server is reachable and the user is authenticated
// If not: throws an error or invokes a redirect
async ping() {
await this.authenticatedFetch(`${this.url}/SETTINGS.md`, { method: "GET" });
}
}