Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update demo with login/logout #149

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions demo/src/routes/+layout.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const load = ({ platform }) => {
return {
clientPrincipal: platform?.clientPrincipal
};
};
7 changes: 6 additions & 1 deletion demo/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<script>
import Header from './Header.svelte';
import './styles.css';

export let data;
</script>

<div class="app">
<Header />
<Header isLoggedIn={!!data.clientPrincipal} />

<main>
{#if data.clientPrincipal}
<p>{JSON.stringify(data.clientPrincipal)}</p>
{/if}
<slot />
</main>

Expand Down
3 changes: 0 additions & 3 deletions demo/src/routes/+page.js

This file was deleted.

11 changes: 11 additions & 0 deletions demo/src/routes/Header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import { page } from '$app/stores';
import logo from '$lib/images/svelte-logo.svg';
import github from '$lib/images/github.svg';

export let isLoggedIn = false;
</script>

<header>
Expand All @@ -25,6 +27,15 @@
<li aria-current={$page.url.pathname.startsWith('/sverdle') ? 'page' : undefined}>
<a href="/sverdle">Sverdle</a>
</li>
{#if isLoggedIn}
<li>
<a href="/.auth/logout" data-sveltekit-reload>Logout</a>
</li>
{:else}
<li>
<a href="/.auth/login/github" data-sveltekit-reload>Login</a>
</li>
{/if}
</ul>
<svg viewBox="0 0 2 3" aria-hidden="true">
<path d="M0,0 L0,3 C0.5,3 0.5,3 1,2 L2,0 Z" />
Expand Down
4 changes: 0 additions & 4 deletions demo/src/routes/about/+page.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@ import { dev } from '$app/environment';
// we don't need any JS on this page, though we'll load
// it in dev so that we get hot module replacement
export const csr = dev;

// since there's no dynamic data here, we can prerender
// it so that it gets served as a static asset in production
export const prerender = true;
9 changes: 0 additions & 9 deletions demo/src/routes/sverdle/how-to-play/+page.js

This file was deleted.