mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-28 09:19:37 +02:00
39 lines
920 B
TypeScript
39 lines
920 B
TypeScript
|
import { DrizzlePostgreSQLAdapter } from "@lucia-auth/adapter-drizzle";
|
||
|
import { Lucia } from "lucia";
|
||
|
import { dev } from "$app/environment";
|
||
|
import { userTable, sessionTable } from "$lib/db/schema";
|
||
|
import { db } from "$lib/db/db.server";
|
||
|
import { Argon2id } from "oslo/password";
|
||
|
|
||
|
const adapter = new DrizzlePostgreSQLAdapter(db, sessionTable, userTable);
|
||
|
|
||
|
export const lucia = new Lucia(adapter, {
|
||
|
sessionCookie: {
|
||
|
attributes: {
|
||
|
secure: !dev,
|
||
|
},
|
||
|
},
|
||
|
getUserAttributes: (attributes) => {
|
||
|
return {
|
||
|
// attributes has the type of DatabaseUserAttributes
|
||
|
username: attributes.username,
|
||
|
};
|
||
|
},
|
||
|
});
|
||
|
|
||
|
declare module "lucia" {
|
||
|
interface Register {
|
||
|
Lucia: typeof lucia;
|
||
|
DatabaseUserAttributes: DatabaseUserAttributes;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
interface DatabaseUserAttributes {
|
||
|
username: string;
|
||
|
}
|
||
|
export interface DatabaseUser {
|
||
|
id: string;
|
||
|
username: string;
|
||
|
hashed_password: string;
|
||
|
}
|