0

When I log with a user the userObject contains empty customData object despite saving a document in custom data collection pointing to the app user.

I tried to follow the documentation:

  1. In the Users section of Mongo Stitch panel I enabled custom data. I chose database, collection (users) and stated User ID Field to be userId. Then I deployed changes.

  2. I have a created and confirmed user.

  3. I copied the user's _id and from shell (from admin account and context of the relevant db) I ran command db.users.insertOne({userId: ObjectId('copied_id'), description: "something"}). It was acknowledged and when I query the collection I see relevant document with userId field having correct ObjectId() value.

  4. I even tried to set read rights to the users collection.

Nonetheless, if I log in with my user, customData object is empty. What can be the cause of this?

Eggon
  • 2,032
  • 2
  • 19
  • 38

1 Answers1

2

same issue here... pebcak :/

I fixed it by setting userId as String, not ObjectId.

Hoping it's not too late ;)

erwan oger
  • 111
  • 5
  • Amazing. It worked. I'd never try try this myself. This must be a bug, I can't imagine this is intended? Thanks a lot! – Eggon Apr 07 '20 at 14:09
  • NO WAY!!! This is the solution!!! The userId field that you defined in your Custom User Data section has to contain the id AS STRING not ObjectId(".....") – Squareoot Jun 09 '22 at 20:07