auth guard

This commit is contained in:
EDRipper 2025-12-10 10:41:08 -05:00
parent 3636ad0b5f
commit d9127deda4
13 changed files with 126 additions and 49 deletions

View file

@ -1,5 +1,5 @@
AIRTABLE_PAT=dummy
AIRTABLE_BASE=dummy
AIRTABLE_BASE_ID=dummy
SESSION_SECRET=dummy
OIDC_ISSUER=dummy
OIDC_CLIENT_ID=dummy

View file

@ -0,0 +1,37 @@
<script>
import { onMount } from 'svelte';
import { checkAuth, user, loading } from '$lib/stores/auth.js';
let { children } = $props();
onMount(() => {
checkAuth().then(authenticated => {
if (!authenticated) {
window.location.href = '/';
}
});
});
</script>
{#if $loading}
<div class="auth-loading">
<p>Loading...</p>
</div>
{:else if $user}
{@render children()}
{:else}
<div class="auth-loading">
<p>Redirecting...</p>
</div>
{/if}
<style>
.auth-loading {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
font-family: 'Departure Mono', monospace;
font-size: 1.5rem;
}
</style>

View file

@ -1,6 +1,7 @@
<script>
import Background from '$lib/components/Background.svelte';
import Navbar from '$lib/components/Navbar.svelte';
import AuthGuard from '$lib/components/AuthGuard.svelte';
import '$lib/styles/global.css';
let { children } = $props();
@ -10,12 +11,14 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</svelte:head>
<Background />
<Navbar active="dash" />
<AuthGuard>
<Background />
<Navbar active="dash" />
<div class="page-content">
{@render children()}
</div>
<div class="page-content">
{@render children()}
</div>
</AuthGuard>
<style>
.page-content {

View file

@ -1,6 +1,7 @@
<script>
import Background from '$lib/components/Background.svelte';
import Navbar from '$lib/components/Navbar.svelte';
import AuthGuard from '$lib/components/AuthGuard.svelte';
import '$lib/styles/global.css';
let { children } = $props();
@ -10,12 +11,14 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</svelte:head>
<Background />
<Navbar active="designs" />
<AuthGuard>
<Background />
<Navbar active="designs" />
<div class="page-content">
{@render children()}
</div>
<div class="page-content">
{@render children()}
</div>
</AuthGuard>
<style>
.page-content {

View file

@ -1,6 +1,7 @@
<script>
import Background from '$lib/components/Background.svelte';
import Navbar from '$lib/components/Navbar.svelte';
import AuthGuard from '$lib/components/AuthGuard.svelte';
import '$lib/styles/global.css';
let { children } = $props();
@ -10,12 +11,14 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</svelte:head>
<Background />
<Navbar active="earn" />
<AuthGuard>
<Background />
<Navbar active="earn" />
<div class="page-content">
{@render children()}
</div>
<div class="page-content">
{@render children()}
</div>
</AuthGuard>
<style>
.page-content {

View file

@ -1,6 +1,7 @@
<script>
import Background from '$lib/components/Background.svelte';
import Navbar from '$lib/components/Navbar.svelte';
import AuthGuard from '$lib/components/AuthGuard.svelte';
import '$lib/styles/global.css';
let { children } = $props();
@ -10,12 +11,14 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</svelte:head>
<Background />
<Navbar active="leaderboard" />
<AuthGuard>
<Background />
<Navbar active="leaderboard" />
<div class="page-content">
{@render children()}
</div>
<div class="page-content">
{@render children()}
</div>
</AuthGuard>
<style>
.page-content {

View file

@ -1,6 +1,7 @@
<script>
import Background from '$lib/components/Background.svelte';
import Navbar from '$lib/components/Navbar.svelte';
import AuthGuard from '$lib/components/AuthGuard.svelte';
import '$lib/styles/global.css';
let { children } = $props();
@ -10,12 +11,14 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</svelte:head>
<Background />
<Navbar active="my-designs" />
<AuthGuard>
<Background />
<Navbar active="my-designs" />
<div class="page-content">
{@render children()}
</div>
<div class="page-content">
{@render children()}
</div>
</AuthGuard>
<style>
.page-content {

View file

@ -1,6 +1,7 @@
<script>
import Background from '$lib/components/Background.svelte';
import Navbar from '$lib/components/Navbar.svelte';
import AuthGuard from '$lib/components/AuthGuard.svelte';
import '$lib/styles/global.css';
let { children } = $props();
@ -10,12 +11,14 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</svelte:head>
<Background />
<Navbar active="stickers" />
<AuthGuard>
<Background />
<Navbar active="stickers" />
<div class="page-content">
{@render children()}
</div>
<div class="page-content">
{@render children()}
</div>
</AuthGuard>
<style>
.page-content {

View file

@ -1,6 +1,7 @@
<script>
import Background from '$lib/components/Background.svelte';
import Navbar from '$lib/components/Navbar.svelte';
import AuthGuard from '$lib/components/AuthGuard.svelte';
import '$lib/styles/global.css';
let { children } = $props();
@ -10,12 +11,14 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</svelte:head>
<Background />
<Navbar active="trade" />
<AuthGuard>
<Background />
<Navbar active="trade" />
<div class="page-content">
{@render children()}
</div>
<div class="page-content">
{@render children()}
</div>
</AuthGuard>
<style>
.page-content {

View file

@ -5,14 +5,14 @@
from: 'LFD',
get: { name: 'Crow thing', img: 'https://hc-cdn.hel1.your-objectstorage.com/s/v3/d2edc2953c00399264ec0c9d93167794a1cb1867_image.png ', quantity: 2 },
give: { name: 'FlavorTownRed', img: 'https://hc-cdn.hel1.your-objectstorage.com/s/v3/80c59fb29dd5a3fbffc1b2297b512ac8cbb719cb_IMG_5304.png', quantity: 1 },
message: "Yo midnight just wrapped and i have one billion left over stickers, would trade most things."
message: "I have loads of midnight stickers lets trade!"
},
{
id: 1,
from: 'LFD',
get: { name: 'Crow thing', img: 'https://hc-cdn.hel1.your-objectstorage.com/s/v3/d2edc2953c00399264ec0c9d93167794a1cb1867_image.png ', quantity: 2 },
give: { name: 'FlavorTownRed', img: 'https://hc-cdn.hel1.your-objectstorage.com/s/v3/80c59fb29dd5a3fbffc1b2297b512ac8cbb719cb_IMG_5304.png', quantity: 1 },
message: "Yo midnight just wrapped and i have one billion left over stickers, would trade most things."
message: "I have loads of midnight stickers lets trade!"
}
];

View file

@ -1,6 +1,7 @@
<script>
import Background from '$lib/components/Background.svelte';
import Navbar from '$lib/components/Navbar.svelte';
import AuthGuard from '$lib/components/AuthGuard.svelte';
import '$lib/styles/global.css';
let { children } = $props();
@ -10,12 +11,14 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</svelte:head>
<Background />
<Navbar active="vault" />
<AuthGuard>
<Background />
<Navbar active="vault" />
<div class="page-content">
{@render children()}
</div>
<div class="page-content">
{@render children()}
</div>
</AuthGuard>
<style>
.page-content {

View file

@ -1,6 +1,7 @@
<script>
import Background from '$lib/components/Background.svelte';
import Navbar from '$lib/components/Navbar.svelte';
import AuthGuard from '$lib/components/AuthGuard.svelte';
import '$lib/styles/global.css';
let { children } = $props();
@ -10,12 +11,14 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</svelte:head>
<Background />
<Navbar active="vote" />
<AuthGuard>
<Background />
<Navbar active="vote" />
<div class="page-content">
{@render children()}
</div>
<div class="page-content">
{@render children()}
</div>
</AuthGuard>
<style>
.page-content {

View file

@ -2,5 +2,18 @@ import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [sveltekit()]
plugins: [sveltekit()],
server: {
proxy: {
'/api': {
target: 'http://localhost:9292',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
},
'/auth': {
target: 'http://localhost:9292',
changeOrigin: true
}
}
}
});