import { PrismaAdapter } from "@lucia-auth/adapter-prisma"; import { PrismaClient } from "@prisma/client"; import { Lucia, TimeSpan } from "lucia"; export const client = new PrismaClient(); const adapter = new PrismaAdapter(client.session, client.user); export const lucia = new Lucia(adapter, { sessionExpiresIn: new TimeSpan(2, "w"), // 2 weeks sessionCookie: { attributes: { secure: process.env.ENV === "PRODUCTION", // set `Secure` flag in HTTPS }, }, getUserAttributes: (attributes) => { return { username: attributes.username, password: attributes.password, staff: attributes.staff, status: attributes.status }; }, }); declare module "lucia" { interface Register { Lucia: typeof lucia; DatabaseUserAttributes: DatabaseUserAttributes; } } interface DatabaseUserAttributes { username: string; password: string; status: string; staff: boolean; }