When a user logs into their account and the user email is not found or password is not a match the current code does not properly connect back to the LoginForm.jsx
The below code worked prior to updating the LoginForm to use react-hook-form. When an invalid password or email was provided the throw new error would populate the login page. Need to fix for react-hook-form.
app/api/auth/[...next-auth]/route.js
if (userEmail) {
const isPasswordCorrect = await bcrypt.compare(
credentials.password,
userHashedPass
);
if (isPasswordCorrect) {
return user;
} else {
console.log("throw new Error => Wrong Credentials Provided");
throw new Error("Wrong Credentials!");
}
} else {
console.log("throw new Error => User Not Found");
throw new Error("User not found!");
}
} catch (err) {
console.log(
`Catch All Errors - route to 'error-page'. Error Msg: ${err}`
);
router.push("/error-page");
}
},
When a user logs into their account and the user email is not found or password is not a match the current code does not properly connect back to the
LoginForm.jsx
The below code worked prior to updating the LoginForm to use react-hook-form. When an invalid password or email was provided the throw new error would populate the login page. Need to fix for react-hook-form.
app/api/auth/[...next-auth]/route.js