auth + player

This commit is contained in:
2024-03-11 15:29:15 +01:00
parent 8b4c542cc3
commit 40d2342211
38 changed files with 6229 additions and 120 deletions

View File

@@ -0,0 +1,18 @@
import { db } from "$lib/db/db.server";
import { sessionsTable, usersTable } from "$lib/db/schema";
import { eq } from "drizzle-orm";
import type { PgUUID } from "drizzle-orm/pg-core";
export async function createSession(user_id: string) {
const session = await db.insert(sessionsTable).values({
user_id: user_id
}).returning({ id: sessionsTable.id });
return session[0].id;
}
export async function validateSession(session_id: string) {
const session = await db.select().from(sessionsTable).where(eq(sessionsTable.id, session_id)).leftJoin(usersTable, eq(usersTable.id, sessionsTable.user_id));
return session[0].users;
}