Lucia Authentication (#8)

* initial lucia installation

* added prismAdapter for lucia

* fixed adapter

* main lucia set

* moved into correct folder

* fixed

* removed npm lock

* removed supabase(i swear)

* Lucia register done

* lucia login done

* removed

* fixed issues with uuid

* fixed all commented issues

* fixed event param

* Update +page.server.ts

Signed-off-by: DanMihailescu <as42554525@yahoo.ca>

* Update lucia.ts

Signed-off-by: DanMihailescu <as42554525@yahoo.ca>

---------

Signed-off-by: DanMihailescu <as42554525@yahoo.ca>
Co-authored-by: Dan Mihailescu <dan.mihailescu5@gmail.com>
This commit is contained in:
DanMihailescu 2024-12-19 20:06:44 -05:00 committed by GitHub
parent 242ec113f6
commit 992eb07f5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 108 additions and 72 deletions

31
src/lib/server/lucia.ts Normal file
View file

@ -0,0 +1,31 @@
import { Lucia } from 'lucia';
import { PrismaAdapter } from '@lucia-auth/adapter-prisma';
import { prisma } from '$lib/server/prisma';
const adapter = new PrismaAdapter(prisma.session, prisma.user);
// expect error (see next section)
export const auth = new Lucia(adapter, {
sessionCookie: {
attributes: {
secure: process.env.NODE_ENV === 'production'
}
},
getUserAttributes: (attributes) => {
return {
email: attributes.email
};
}
});
declare module 'lucia' {
interface Register {
Lucia: typeof Lucia;
DatabaseUserAttributes: DatabaseUserAttributes;
}
}
interface DatabaseUserAttributes {
email: string;
}
export type Auth = typeof auth;