diff --git a/src/authTokens.json b/src/authTokens.json new file mode 100644 index 0000000..60e857b --- /dev/null +++ b/src/authTokens.json @@ -0,0 +1,4 @@ +[ + "1234", + "5678" +] \ No newline at end of file diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 3d81f50..c18e2c2 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,7 +1,15 @@ import { redirect } from "@sveltejs/kit"; +import validAuthTokens from './authTokens.json'; export async function handle({ event, resolve }) { - event.locals.authenticated = true; + const cookie = event.cookies.get('authToken'); + if (typeof cookie !== 'undefined') { + event.locals.authenticated = validAuthTokens.includes(cookie); + } + else { + event.locals.authenticated = false; + } + if (event.url.pathname.startsWith('/admin')) { if (!event.locals.authenticated) { diff --git a/src/routes/Header.svelte b/src/routes/Header.svelte index a7a9a36..2be1cc5 100644 --- a/src/routes/Header.svelte +++ b/src/routes/Header.svelte @@ -1,8 +1,13 @@ + +
@@ -30,6 +35,9 @@
  • About
  • +
  • + +
  • Settings

    +
    + +
    + + + + {#if showAuthSaved} +

    Saved!

    + {/if} +
    +
    + Show Game Groups:
    + Group B
    + Ungrouped
    + +
    + +
    +
    +
    + + + + + \ No newline at end of file