hiteshchoudhary / ama-app

https://truefeedback.in
321 stars 63 forks source link

for same email username is not changed issue in the signup route logic #18

Open Hariom8799 opened 5 months ago

Hariom8799 commented 5 months ago

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

  1. forgot username route
  2. change the username according to second attempt

image