customData and uid from custom authentication

ive worked with email authentication provider, works perfect. but what really upset me is that i could not transfer my existing user to another project if i needed to. therefore im creating my own custom authentication. but after trying it out, i figure inconsistancy with custom login:

  1. returning document id of linked users collection does not seems to point to the _id of the linked custom data “users” collection. im getting some weird id that does not point to both users._id nor users.uid
  2. customData is always empty {}

linked users collection

sample result:

{
  "roles": [
    "superadmin"
  ],
  "teams": [
    "619f91d32b2b45517a26b39b"
  ],
  "name": "Mr Who",
  "email": "who@example.com",
  "id": "627247134471c9b2a92b3a9f",
  "customData": {
    "roles": [
      "superadmin"
    ],
    "teams": [
      "619f91d32b2b45517a26b39b"
    ]
  }
}

returned currentUser.id
6311bc10a7aa86620ce6ec7f

can see here, im returning string of users.id 627247134471c9b2a92b3a9f
but im getting 6311bc10a7aa86620ce6ec7f returned.

1 Like

@James_Tan1 Today, the custom authentication and custom user data are a bit separate. In order to achieve what you are looking for you would need to use an Auth Trigger which could then map the document id to the currentUser’s id. From there you would then refresh the custom user data on the client side Realm SDK and you should see your custom user data.

We realize this is not ideal and we have a design to add new functionality to custom authentication and custom user data which will enable you to do this mapping at custom authentication time all in one step. We should get started on this work soon.

2 Likes

hi

highly appreciate your response, glad that im getting some attention to this matter. im also concern that custom authentication does not return the same uid like email provider. seems like my only work around is to query users collection separately. but without knowing id means ive to query by email or my customer username.

thank you.

and also it will be great if we could have a way to transfer user to another project if possible.

What’s the use case for migrating users between apps? Generally, this is where we would recommend integrating with a fully-fledged IDP and 3rd party JWT provider like Auth0 or similar as they are more fully featured and would support moving authentication status around different App Services apps.

1 Like

like firebase? hehe. alright noted