auth & sidebar

This commit is contained in:
Face 2025-05-22 13:17:11 +03:00
parent 8086aa8f38
commit af078e7ba2
74 changed files with 3262 additions and 133 deletions

View file

@ -0,0 +1,22 @@
import { auth } from '$lib/auth';
import { db } from '$lib/server/db';
import { eq } from 'drizzle-orm';
import type { LayoutServerLoad } from './$types';
import { dev } from '$app/environment';
export const load: LayoutServerLoad = async (event) => {
event.setHeaders({
'Cache-Control': dev
? 'no-cache'
: 'private, max-age=30'
});
const sessionResponse = await auth.api.getSession({
headers: event.request.headers
});
return {
userSession: sessionResponse?.user || null,
url: event.url.pathname,
};
};

View file

@ -1,6 +1,95 @@
<script lang="ts">
import '../app.css';
let { children } = $props();
import * as Sidebar from '$lib/components/ui/sidebar/index.js';
import AppSidebar from '$lib/components/self/AppSidebar.svelte';
import { USER_DATA } from '$lib/stores/user-data';
import { onMount } from 'svelte';
import { invalidateAll } from '$app/navigation';
let { data, children } = $props<{
data: { userSession?: any };
children: any;
}>();
$effect(() => {
if (data?.userSession) {
USER_DATA.set(data.userSession);
} else {
USER_DATA.set(null);
}
});
onMount(() => {
console.log(
`%c .--
.=--:
:=*#*:
.=******+#*.
.+*****+*#*+**#*
:**++**####*###*++#-
=***+*####******###*+#*
=***++#####***+++***%#*+*%:
=*++*###+=++++====****##%#**#=
.+**+=*##=*###+####*#+++*###%#**#=
:#*=**####=*#+-*##=-*##+**#####%##*%=
. :+**++*###***++=*#++=*###**######%%%####:.--:
.---=******+*###****=***=-**+##*#+*###%%%***##%%#=--:
:-: =#++**##***+++=******#*=##**#%%%##*#%*:
.**++*##***++**+**#*####+*%%#**#%+.
+***+##*=**=++******##%%*####:
-#+++###***+*######%####%+
.#*++*##**#####%%#**##=
*#*+*######%%#*###=
+#**#%%%%##**##-
=#***#*###%+.
-%#####*:
.=%#*:
.=--=.
::`,
'color: #4962ee; font-family: monospace; font-size: 12px; font-weight: bold; text-shadow: 2px 2px rgba(0,0,0,0.2);'
);
console.log(
'%c Welcome to Rugplay! DO NOT FUCKING PASTE ANYTHING IN THE CONSOLE UNLESS YOU KNOW WHAT YOU ARE DOING.',
'color: #4962ee; font-family: monospace; font-size: 12px; font-weight: bold; text-shadow: 2px 2px rgba(0,0,0,0.2);'
);
console.log(
'%c A product by Outpoot.com',
'color: #4962ee; font-family: monospace; font-size: 12px; font-weight: bold; text-shadow: 2px 2px rgba(0,0,0,0.2);'
);
const url = new URL(window.location.href);
if (url.searchParams.has('signedIn')) {
url.searchParams.delete('signedIn');
window.history.replaceState({}, '', url);
invalidateAll();
}
});
</script>
{@render children()}
<Sidebar.Provider>
<AppSidebar />
<Sidebar.Inset class="sidebar-container">
<header
class="group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 flex h-12 shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear"
>
<div class="flex w-full items-center gap-4 px-4 lg:px-6">
<Sidebar.Trigger class="-ml-1" />
<h1 class="mr-6 text-base font-medium">test</h1>
</div>
</header>
<div class="main-content-area">
<div class="@container/main flex flex-col gap-2">
<div class="flex flex-col gap-4 md:gap-6">
<div class="px-4 md:py-4 lg:px-6">
{@render children()}
</div>
</div>
</div>
</div>
</Sidebar.Inset>
</Sidebar.Provider>