Skip to content

Commit

Permalink
login validation error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dhatGuy committed Jun 20, 2023
1 parent fba852d commit d5251ce
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d5251ce

Please sign in to comment.