From 8da83b3f8d800a3f1fb6006bbc84de917c587d91 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 25 Mar 2023 17:07:11 +0100 Subject: [PATCH] fix(frontend): don't show login button if user is logged in, redirect to profile on login --- frontend/src/routes/+page.svelte | 7 ++++++- frontend/src/routes/auth/login/CallbackPage.svelte | 3 ++- frontend/src/routes/auth/login/discord/+page.svelte | 2 +- .../src/routes/auth/login/mastodon/[instance]/+page.svelte | 2 +- .../src/routes/auth/login/misskey/[instance]/+page.svelte | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index 3261975..3c1fe4c 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -1,6 +1,7 @@ @@ -16,7 +17,11 @@

Create and share all your pronouns

- + {#if $userStore} + + {:else} + + {/if}

diff --git a/frontend/src/routes/auth/login/CallbackPage.svelte b/frontend/src/routes/auth/login/CallbackPage.svelte index 2993edf..e57ef3d 100644 --- a/frontend/src/routes/auth/login/CallbackPage.svelte +++ b/frontend/src/routes/auth/login/CallbackPage.svelte @@ -35,7 +35,8 @@ localStorage.setItem("pronouns-token", token); localStorage.setItem("pronouns-user", JSON.stringify(user)); userStore.set(user); - goto("/"); + addToast({ header: "Logged in", body: "Successfully logged in!" }); + goto(`/@${user.name}`); } }); diff --git a/frontend/src/routes/auth/login/discord/+page.svelte b/frontend/src/routes/auth/login/discord/+page.svelte index e7336ec..703e10c 100644 --- a/frontend/src/routes/auth/login/discord/+page.svelte +++ b/frontend/src/routes/auth/login/discord/+page.svelte @@ -25,7 +25,7 @@ localStorage.setItem("pronouns-user", JSON.stringify(resp.user)); userStore.set(resp.user); addToast({ header: "Welcome!", body: "Signed up successfully!" }); - goto("/"); + goto(`/@${resp.user.name}`); } catch (e) { data.error = e as APIError; } diff --git a/frontend/src/routes/auth/login/mastodon/[instance]/+page.svelte b/frontend/src/routes/auth/login/mastodon/[instance]/+page.svelte index 4570320..a192f05 100644 --- a/frontend/src/routes/auth/login/mastodon/[instance]/+page.svelte +++ b/frontend/src/routes/auth/login/mastodon/[instance]/+page.svelte @@ -26,7 +26,7 @@ localStorage.setItem("pronouns-user", JSON.stringify(resp.user)); userStore.set(resp.user); addToast({ header: "Welcome!", body: "Signed up successfully!" }); - goto("/"); + goto(`/@${resp.user.name}`); } catch (e) { data.error = e as APIError; } diff --git a/frontend/src/routes/auth/login/misskey/[instance]/+page.svelte b/frontend/src/routes/auth/login/misskey/[instance]/+page.svelte index ed9465f..24bfab4 100644 --- a/frontend/src/routes/auth/login/misskey/[instance]/+page.svelte +++ b/frontend/src/routes/auth/login/misskey/[instance]/+page.svelte @@ -26,7 +26,7 @@ localStorage.setItem("pronouns-user", JSON.stringify(resp.user)); userStore.set(resp.user); addToast({ header: "Welcome!", body: "Signed up successfully!" }); - goto("/"); + goto(`/@${resp.user.name}`); } catch (e) { data.error = e as APIError; }