Skip to content

Commit

Permalink
fix: 🐛 lucia userId type
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinWu098 committed Feb 1, 2024
1 parent 874b8ef commit ba0b9ac
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
Binary file modified prisma/dev.db
Binary file not shown.
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 9 additions & 6 deletions src/app.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,13 +24,11 @@ declare global {
errorId?: string;
}
}
}

/// <reference types="lucia-auth" />
declare global {
namespace Lucia {
type Auth = import("$lib/server/lucia").Auth;
type Auth = CustomAuth;

type UserAttributes = {
userId: string;
email: string;
firstName: string;
lastName: string;
Expand Down
4 changes: 1 addition & 3 deletions src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
@@ -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 };
};
2 changes: 1 addition & 1 deletion src/routes/auth/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="mt-48 flex min-h-[100vh] justify-center">
<div class="mx-2 w-[450px] md:mx-16">
{#if data.user}
<p>{data.user.firstName} {data.user.lastName} {data.user.token}</p>
<p>{data.user.firstName} {data.user.lastName} {data.user.userId}</p>

<div>
<form use:enhance action="/auth/logout" method="post">
Expand Down

0 comments on commit ba0b9ac

Please sign in to comment.