From 4a4cf3c3a689157f633051524c0533c013384595 Mon Sep 17 00:00:00 2001 From: Yannic Kilcher Date: Sat, 31 Dec 2022 17:32:02 +0100 Subject: [PATCH] saving user to the dabase when using the debug credentials provider --- website/src/pages/api/auth/[...nextauth].ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/website/src/pages/api/auth/[...nextauth].ts b/website/src/pages/api/auth/[...nextauth].ts index e0d818c5..48ca2f44 100644 --- a/website/src/pages/api/auth/[...nextauth].ts +++ b/website/src/pages/api/auth/[...nextauth].ts @@ -43,10 +43,19 @@ if (boolean(process.env.DEBUG_LOGIN) || process.env.NODE_ENV === "development") username: { label: "Username", type: "text" }, }, async authorize(credentials) { - return { + const user = { id: credentials.username, name: credentials.username, }; + // save the user to the database + await prisma.user.upsert({ + where: { + id: user.id, + }, + update: {}, + create: user, + }); + return user; }, }) );