Open illusionrs opened 4 years ago
This looks like a Mongoose error, when the password is not valid (as string in this case) according to the model's Schema. This most likely occurs with the password 'hasher' (eg. bcrypt) not completing the hashing process before the attempt to create a user... Solution: use async/await with your hashing process, for 'bcrypt' example:
const salt = await bcrypt.genSalt(10)
const hashedPassword = await bcrypt.hash(password, salt)
newUser.password = hashedPassword
Don't forget to put 'async' before the function that's calling it... I hope this helps
I am getting this error user validation failed: password: Cast to string failed for value "Promise { }" at path "password"