fix(frontend): don't show login button if user is logged in, redirect to profile on login
This commit is contained in:
parent
2cb735a0db
commit
8da83b3f8d
|
@ -1,6 +1,7 @@
|
|||
<script lang="ts">
|
||||
import { PUBLIC_BASE_URL } from "$env/static/public";
|
||||
import { Button } from "sveltestrap";
|
||||
import { userStore } from "$lib/store";
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
|
@ -16,7 +17,11 @@
|
|||
<p class="fs-3">Create and share <em>all</em> your pronouns</p>
|
||||
|
||||
<p>
|
||||
<Button href="/auth/login" color="success" size="lg">Log in or sign up</Button>
|
||||
{#if $userStore}
|
||||
<Button href="/@{$userStore.name}" color="secondary" size="lg">Go to your profile</Button>
|
||||
{:else}
|
||||
<Button href="/auth/login" color="success" size="lg">Log in or sign up</Button>
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -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}`);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue