in the signup route
if (existingUserByEmail) {
if (existingUserByEmail.isVerified) {
return Response.json(
{
success: false,
message: 'User already exists with this email',
},
{ status: 400 }
);
} else {
const hashedPassword = await bcrypt.hash(password, 10);
existingUserByEmail.password = hashedPassword;
existingUserByEmail.verifyCode = verifyCode;
existingUserByEmail.verifyCodeExpiry = new Date(Date.now() + 3600000);
await existingUserByEmail.save();
}
}
here changed the user info but not the username when the user is not verified so when we verify it the username is not found message occurred
so the user stuck the situation where not able to signup with same email when he is not verified
here we had two solutions
in the signup route if (existingUserByEmail) { if (existingUserByEmail.isVerified) { return Response.json( { success: false, message: 'User already exists with this email', }, { status: 400 } ); } else { const hashedPassword = await bcrypt.hash(password, 10); existingUserByEmail.password = hashedPassword; existingUserByEmail.verifyCode = verifyCode; existingUserByEmail.verifyCodeExpiry = new Date(Date.now() + 3600000); await existingUserByEmail.save(); } }
here changed the user info but not the username when the user is not verified so when we verify it the username is not found message occurred so the user stuck the situation where not able to signup with same email when he is not verified here we had two solutions