35 lines
687 B
TypeScript
35 lines
687 B
TypeScript
import { PrismaAdapter } from '@lucia-auth/adapter-prisma'
|
|
import { Lucia } from 'lucia'
|
|
import prisma from '../prisma/client.ts'
|
|
|
|
declare module 'lucia' {
|
|
interface Register {
|
|
Lucia: typeof Lucia
|
|
UserId: string
|
|
DatabaseUserAttributes: DatabaseUserAttributes
|
|
}
|
|
}
|
|
|
|
interface DatabaseUserAttributes {
|
|
id: string
|
|
displayName: string
|
|
username: string
|
|
}
|
|
|
|
export const auth = new Lucia(new PrismaAdapter(prisma.session, prisma.user), {
|
|
sessionCookie: {
|
|
attributes: {
|
|
sameSite: 'none',
|
|
},
|
|
},
|
|
getUserAttributes: ({ id, displayName, username }) => {
|
|
return {
|
|
id,
|
|
displayName,
|
|
username,
|
|
}
|
|
},
|
|
})
|
|
|
|
export type Auth = typeof auth
|