Skip to content

Commit

Permalink
login validation error fix (#42)
Browse files Browse the repository at this point in the history
Co-authored-by: Federico Minaya <[email protected]>
  • Loading branch information
dhatGuy and fedeya authored Jun 28, 2023
1 parent cdf5b93 commit f362f38
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 @@ -79,12 +79,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 f362f38

Please sign in to comment.