From ed738f64c80f3382b299223f4a061e781f088add Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Mon, 18 Nov 2024 20:31:17 -0800 Subject: [PATCH] Handle failed space auth --- src/app/commands.ts | 9 ++- src/app/components/SpaceAuthError.svelte | 73 +++++++++++++++++++++ src/app/components/SpaceInviteAccept.svelte | 2 +- src/routes/spaces/[relay]/+layout.svelte | 24 ++++--- 4 files changed, 97 insertions(+), 11 deletions(-) create mode 100644 src/app/components/SpaceAuthError.svelte diff --git a/src/app/commands.ts b/src/app/commands.ts index e0e00e91..f58afdb1 100644 --- a/src/app/commands.ts +++ b/src/app/commands.ts @@ -330,10 +330,15 @@ export const checkRelayAuth = async (url: string, timeout = 3000) => { } export const attemptRelayAccess = async (url: string, claim = "") => { - const checks = [checkRelayProfile, checkRelayConnection, checkRelayAccess, checkRelayAuth] + const checks = [ + () => checkRelayProfile(url), + () => checkRelayConnection(url), + () => checkRelayAccess(url, claim), + () => checkRelayAuth(url), + ] for (const check of checks) { - const error = await check(url) + const error = await check() if (error) { return error diff --git a/src/app/components/SpaceAuthError.svelte b/src/app/components/SpaceAuthError.svelte new file mode 100644 index 00000000..85043787 --- /dev/null +++ b/src/app/components/SpaceAuthError.svelte @@ -0,0 +1,73 @@ + + +
+ +
Access Error
+
We couldn't connect you to this space.
+
+

We received an error from the relay indicating you don't have access to this space.

+

+ {error} +

+

If you have one, you can try entering an invite code below to request access.

+ +

Invite code

+ +

Enter an invite code provided to you by the admin of the relay.

+
+ + + + +
diff --git a/src/app/components/SpaceInviteAccept.svelte b/src/app/components/SpaceInviteAccept.svelte index 2b795d06..83ded1dc 100644 --- a/src/app/components/SpaceInviteAccept.svelte +++ b/src/app/components/SpaceInviteAccept.svelte @@ -62,7 +62,7 @@ let url = "" let loading = false - $: linkIsValid = Boolean(tryCatch(() => isRelayUrl(normalizeRelayUrl(url)))) + $: linkIsValid = Boolean(tryCatch(() => isRelayUrl(normalizeRelayUrl(url.split("|")[0]))))
diff --git a/src/routes/spaces/[relay]/+layout.svelte b/src/routes/spaces/[relay]/+layout.svelte index cc348f47..22965ab2 100644 --- a/src/routes/spaces/[relay]/+layout.svelte +++ b/src/routes/spaces/[relay]/+layout.svelte @@ -1,15 +1,17 @@