From c9ccf24c13aac461bc97073f28ce53043d0baed1 Mon Sep 17 00:00:00 2001 From: Dominik Stahl Date: Sat, 14 Jun 2025 11:45:14 +0200 Subject: [PATCH] feat(auth): update user lookup to support name or email in authentication When testing api endpoints make sure to login with a real user (not with the dev hardcoded user) by either registering one with a password other than "password" or setting DISABLE_AUTH_TEST_USER to "true" (`DISABLE_AUTH_TEST_USER=true yarn dev`) --- src/auth.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/auth.ts b/src/auth.ts index 6e623b0..ebf6c82 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -25,7 +25,7 @@ const providers: Provider[] = [ Credentials({ credentials: { password: { label: 'Password', type: 'password' } }, async authorize(c) { - if (process.env.NODE_ENV === 'development' && c.password === 'password') + if (process.env.NODE_ENV === 'development' && process.env.DISABLE_AUTH_TEST_USER !== 'true' && c.password === 'password') return { id: 'test', name: 'Test User', @@ -37,7 +37,7 @@ const providers: Provider[] = [ const { email, password } = await loginSchema.parseAsync(c); const user = await prisma.user.findFirst({ - where: { email }, + where: { OR: [{ email }, { name: email }] }, include: { accounts: true }, });