auth + player
This commit is contained in:
18
src/lib/services/auth.server.ts
Normal file
18
src/lib/services/auth.server.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user