blob: bf1b55c23a71f201da11a4934ec8dee82487c11b [file] [log] [blame]
Filip Kujawa3a0fbf32023-03-31 14:25:26 -07001<script>
2 import '../app.css';
3
4 import { getAuth, onAuthStateChanged } from 'firebase/auth';
5 import authStore from '$lib/authStore';
6 import { uid, username } from '$lib/store';
7 import { onMount } from 'svelte';
8 import { app } from '$lib/firestore';
9 import { goto } from '$app/navigation';
10 import { inject } from '@vercel/analytics';
11
12 onMount(() => {
13 const auth = getAuth(app);
14 onAuthStateChanged(auth, (user) => {
15 if (!user) {
16 goto('/');
17 } else {
18 uid.update((uid) => user.uid);
19 username.update((username) => user.displayName);
20 }
21 authStore.set({
22 isLoggedIn: user !== null,
23 user,
24 firebaseControlled: true
25 });
26 });
27 });
28</script>
29
30<body class="overflow-x-hidden">
31 <div class="min-h-screen bg-white ">
32 <slot />
33 </div>
34</body>