Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3d0106d8f | ||
|
|
e2068dd89a | ||
|
|
a2f845f228 | ||
|
|
1a497d402d | ||
|
|
924bbd4285 | ||
|
|
58d37ee02b |
@ -17,6 +17,11 @@ interface DatabaseUserAttributes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const auth = new Lucia(new PrismaAdapter(prisma.session, prisma.user), {
|
export const auth = new Lucia(new PrismaAdapter(prisma.session, prisma.user), {
|
||||||
|
sessionCookie: {
|
||||||
|
attributes: {
|
||||||
|
sameSite: 'none',
|
||||||
|
},
|
||||||
|
},
|
||||||
getUserAttributes: ({ id, displayName, username }) => {
|
getUserAttributes: ({ id, displayName, username }) => {
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
|
|||||||
@ -24,11 +24,13 @@ export default fp(async (fastify) => {
|
|||||||
|
|
||||||
if (session && session.fresh) {
|
if (session && session.fresh) {
|
||||||
const cookie = auth.createSessionCookie(session.id)
|
const cookie = auth.createSessionCookie(session.id)
|
||||||
|
|
||||||
reply.setCookie(cookie.name, cookie.value, cookie.attributes)
|
reply.setCookie(cookie.name, cookie.value, cookie.attributes)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!session) {
|
if (!session) {
|
||||||
const blank = auth.createBlankSessionCookie()
|
const blank = auth.createBlankSessionCookie()
|
||||||
|
|
||||||
reply.setCookie(blank.name, blank.value, blank.attributes)
|
reply.setCookie(blank.name, blank.value, blank.attributes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,13 @@ const fastify = Fastify({
|
|||||||
logger: true,
|
logger: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
fastify.register(FastifyCors)
|
fastify.register(FastifyCors, {
|
||||||
|
origin: [
|
||||||
|
'http://localhost:3000',
|
||||||
|
'http://tauri.localhost',
|
||||||
|
],
|
||||||
|
credentials: true,
|
||||||
|
})
|
||||||
|
|
||||||
fastify.register(FastifyCookie)
|
fastify.register(FastifyCookie)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user