Custom Auth User ID add to user document

I am able to login or create a new realm user based on user document field search but would like to know best way to insert that realm user Id into the document userID field so I can access customData?

Tried adding insert inside the custom auth function but could not access context.user or realm user.id.

Much appreciated in advance. . .

Much appreciated, that tag helped get it sorted. . .