From d5251ce668495a80abcc66f2c6b9409b2f6415f7 Mon Sep 17 00:00:00 2001 From: Joseph Odunsi Date: Tue, 20 Jun 2023 22:21:45 +0100 Subject: [PATCH] login validation error fix --- src/credentials.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/credentials.ts b/src/credentials.ts index 07fdbc1..0909439 100644 --- a/src/credentials.ts +++ b/src/credentials.ts @@ -68,12 +68,14 @@ export const SanityCredentials = ( } }, async authorize(credentials) { - const { _id, ...user } = await client.fetch(getUserByEmailQuery, { + const response = await client.fetch(getUserByEmailQuery, { userSchema, email: credentials?.email }); - if (!user) throw new Error('Email does not exist'); + if (!response) throw new Error('Email does not exist'); + + const { _id, ...user } = response; if (await argon2.verify(user.password, credentials?.password!)) { return {