From ba0b9ac9da1b1dbbeaa77b80d2802269b1a230b9 Mon Sep 17 00:00:00 2001 From: Kevin Wu Date: Wed, 31 Jan 2024 16:24:13 -0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20lucia=20userId=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prisma/dev.db | Bin 57344 -> 57344 bytes prisma/schema.prisma | 2 +- src/app.d.ts | 15 +++++++++------ src/routes/+layout.server.ts | 4 +--- src/routes/auth/+page.svelte | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/prisma/dev.db b/prisma/dev.db index 35a0eb9b410465f94728e4d5b9bc40c6176c2580..12d39a68c20da5a4c44e092ecc0a9ffea8d8ee94 100644 GIT binary patch delta 1000 zcmb_b&r1|x7@lz&zuj49KHIV)4T`-K>*mb&W9A!$To5HIsLK`|1ZTeaMpxG#u&XW_ zxJH)Zgq&MTH~^M$$lV!1f~WXZHGhnWoL9877BAlJ%y0>>@ErbFE@^n@vI`dT9Y zr$)Qi9&~g8xFo^vunE7xrO3E0;Kd6{Rz3y^>MsY@(m-oTFmKfKJzeU`r)pX&=K4un z-xvn!&~usn4P^I(RhNp|+db zZ`FHuGwMWERlTX|YDwT#Ya!&!5BymkETYxwN??~n(RBhmPifgIRgU4yn^WfJeR*?d zytN}toFxryQjuKl3#;u!5K|W0kK|R&@aR#|}8fT#Y i-=*u$=%ewE=o_&fUtm)ojnZE&{cnGgiJl&P?Dz$pawf)kGO*MyrhpOZWxYcy}=H&*!(}yUSO@C(XNKv!cQh-pxB?eVDk| z_&XW+-|}zdzqwgJA(emP0pgSe?GGko6cnR0N0HZAFyuL3A@25ro_e0z$e7p&Be}T!Y#_x$Gd}j z4&ThpG70-QCoa(6%%1g^6|24V)iB|k{2LL@>8}Rb$qlq~!VSKO3$!P5&;N<$i1qVf n8d3aFUrmft_>_1ffkD9A$bXanD9~P!3x>SFVAvdacR3RPU94x& diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c83594b6..cdcf9439 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -16,7 +16,7 @@ datasource db { // Do not modify anything above this line unless you know what you are doing. model User { - id String @id @unique + id String @id @unique @default(cuid()) email String @unique firstName String diff --git a/src/app.d.ts b/src/app.d.ts index d0c33b24..b82b6bce 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -1,11 +1,16 @@ // See https://kit.svelte.dev/docs/types#app // for information about these interfaces import "unplugin-icons/types/svelte"; +import "lucia-auth"; + +import type { AuthRequest } from "lucia"; + +import type { Auth as CustomAuth } from "$lib/server/lucia"; declare global { namespace App { interface Locals { - auth: import("lucia").AuthRequest; + auth: AuthRequest; user: Lucia.UserAttributes; startTimer: number; error: string; @@ -19,13 +24,11 @@ declare global { errorId?: string; } } -} - -/// -declare global { namespace Lucia { - type Auth = import("$lib/server/lucia").Auth; + type Auth = CustomAuth; + type UserAttributes = { + userId: string; email: string; firstName: string; lastName: string; diff --git a/src/routes/+layout.server.ts b/src/routes/+layout.server.ts index 81d7d3ee..7bf2fa1b 100644 --- a/src/routes/+layout.server.ts +++ b/src/routes/+layout.server.ts @@ -1,5 +1,3 @@ -import type { User } from "@prisma/client"; - -export const load = async (event: { locals: { user: User } }) => { +export const load = async (event) => { return { user: event.locals.user }; }; diff --git a/src/routes/auth/+page.svelte b/src/routes/auth/+page.svelte index ed40efdb..4eda3326 100644 --- a/src/routes/auth/+page.svelte +++ b/src/routes/auth/+page.svelte @@ -13,7 +13,7 @@
{#if data.user} -

{data.user.firstName} {data.user.lastName} {data.user.token}

+

{data.user.firstName} {data.user.lastName} {data.user.userId}