fix userid serialization due to bigint format bug

This commit is contained in:
Khalim Conn-Kowlessar 2023-08-02 10:41:18 +01:00
parent 9e16205696
commit 3e2905a6dd
2 changed files with 3 additions and 4 deletions

View file

@ -36,7 +36,6 @@ export const AuthOptions: NextAuthOptions = {
if (user === null || user.email === null) {
return "/beta";
}
const dbUser: User[] = await db
.select()
.from(userTable)
@ -65,8 +64,8 @@ export const AuthOptions: NextAuthOptions = {
}
// Set the user's ID from your database
user.dbId = dbUser[0].id;
// Because bigint isn't serializable, we need to convert it to a string
user.dbId = dbUser[0].id.toString();
return true;
} catch (error) {
console.error("Error during sign-in: ", error);

View file

@ -9,6 +9,6 @@ declare module "next-auth" {
} & DefaultSession["user"];
}
interface User {
dbId: bigint;
dbId: string;
}
}