2023-05-21 05:18:04 +00:00
|
|
|
// lib/server/lucia.ts
|
2023-07-30 05:00:51 +00:00
|
|
|
import { lucia } from 'lucia';
|
|
|
|
|
import { sveltekit } from 'lucia/middleware';
|
|
|
|
|
import { prisma } from '@lucia-auth/adapter-prisma';
|
2023-05-21 05:18:04 +00:00
|
|
|
import { dev } from '$app/environment';
|
2023-11-05 00:03:28 +00:00
|
|
|
import prisma_client from '$lib/prisma';
|
|
|
|
|
|
|
|
|
|
// export const prisma_client = new PrismaClient();
|
2023-07-30 05:00:51 +00:00
|
|
|
|
2023-05-21 05:18:04 +00:00
|
|
|
export const auth = lucia({
|
|
|
|
|
env: dev ? 'DEV' : 'PROD',
|
|
|
|
|
middleware: sveltekit(),
|
2023-11-05 00:03:28 +00:00
|
|
|
adapter: prisma(prisma_client),
|
2023-07-30 05:00:51 +00:00
|
|
|
getUserAttributes: (databaseUser) => {
|
2023-05-21 05:18:04 +00:00
|
|
|
return {
|
2023-07-30 05:00:51 +00:00
|
|
|
username: databaseUser.username,
|
|
|
|
|
email: databaseUser.email,
|
|
|
|
|
firstName: databaseUser.firstName,
|
|
|
|
|
lastName: databaseUser.lastName,
|
|
|
|
|
verified: databaseUser.verified,
|
|
|
|
|
receiveEmail: databaseUser.receiveEmail,
|
|
|
|
|
token: databaseUser.token,
|
|
|
|
|
theme: databaseUser.theme
|
2023-05-21 05:18:04 +00:00
|
|
|
};
|
2023-06-16 06:28:49 +00:00
|
|
|
},
|
|
|
|
|
experimental: {
|
|
|
|
|
debugMode: false
|
2023-05-21 05:18:04 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export type Auth = typeof auth;
|