hestia/lucia.ts
2024-12-15 12:46:37 -05:00

32 lines
No EOL
777 B
TypeScript

import { Lucia } from "lucia";
import { PrismaAdapter } from "@lucia-auth/adapter-prisma";
import { PrismaClient } from "@prisma/client";
const client = new PrismaClient();
const adapter = new PrismaAdapter(client.session, client.user)
// expect error (see next section)
export const auth = new Lucia(adapter, {
sessionCookie: {
attributes: {
// secure: process.env.NODE_ENV === "production"
}
},
getUserAttributes: (attributes)=>{
return {
email: attributes.email
}
}
});
declare module "lucia" {
interface Register {
Lucia: typeof Lucia;
DatabaseUserAttributes: DatabaseUserAttributes
}
}
interface DatabaseUserAttributes {
email: string
}
export type Auth = typeof auth;