You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I experiment a bug with MongoDB using code from the shopping application example. Specifically, I copied the code for Login/User authentication in my own code (with no modifications).
Remember there are two models: User and UserCredentials linked by a HasOne relation. when you create a new user you store the password in UserCredentials with:
The problem here is when you try to get the credentials with:
await this.userCredentials(userId).get();
you get an ENTITY_NOT_FOUND error. The reason is the last line of code try to get the credentials with userId being an ObjectId, not a string. So the create function should make it an ObjectId. I checked, manually changing userId type to ObjectId make it works.
I am very confused about this behavior. What should I do?
Steps to reproduce
I experiment a bug with MongoDB using code from the shopping application example. Specifically, I copied the code for Login/User authentication in my own code (with no modifications).
Remember there are two models: User and UserCredentials linked by a HasOne relation. when you create a new user you store the password in UserCredentials with:
await this.userRepository.userCredentials(savedUser.id).create({ password });
and the result in MongoDB is:
_id: ObjectId("5e2f24850570630bc9e3f558")
password: "$2a$10$/ZGqyHNotLYeKT7uSotXpuIHVMWmfEVROMKRqtIgEufqg0plibkC2"
userId:"5e2f24850570630bc9e3f557"
The problem here is when you try to get the credentials with:
await this.userCredentials(userId).get();
you get an
ENTITY_NOT_FOUND
error. The reason is the last line of code try to get the credentials with userId being an ObjectId, not a string. So the create function should make it an ObjectId. I checked, manually changing userId type to ObjectId make it works.I am very confused about this behavior. What should I do?
Related Issues
#3720
#3456
The text was updated successfully, but these errors were encountered: