session livekit token
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { PrismaAdapter } from '@lucia-auth/adapter-prisma'
|
||||
import { Lucia } from 'lucia'
|
||||
import { Lucia, TimeSpan } from 'lucia'
|
||||
import prisma from '../prisma/client.ts'
|
||||
|
||||
declare module 'lucia' {
|
||||
interface Register {
|
||||
Lucia: typeof Lucia
|
||||
Lucia: typeof auth
|
||||
UserId: string
|
||||
DatabaseUserAttributes: DatabaseUserAttributes
|
||||
DatabaseSessionAttributes: DatabaseSessionAttributes
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +17,14 @@ interface DatabaseUserAttributes {
|
||||
username: string
|
||||
}
|
||||
|
||||
interface DatabaseSessionAttributes {
|
||||
livekitToken: string | null
|
||||
}
|
||||
|
||||
export const SESSION_EXPIRES_IN = new TimeSpan(30, 'd')
|
||||
|
||||
export const auth = new Lucia(new PrismaAdapter(prisma.session, prisma.user), {
|
||||
sessionExpiresIn: SESSION_EXPIRES_IN,
|
||||
sessionCookie: {
|
||||
attributes: {
|
||||
sameSite: 'none',
|
||||
@@ -29,6 +37,11 @@ export const auth = new Lucia(new PrismaAdapter(prisma.session, prisma.user), {
|
||||
username,
|
||||
}
|
||||
},
|
||||
getSessionAttributes: ({ livekitToken }) => {
|
||||
return {
|
||||
livekitToken,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export type Auth = typeof auth
|
||||
|
||||
Reference in New Issue
Block a user