Data format, custom attributes etc for login script return object?

Hi,

In a custom database connection’s login script, with auto migration activated, I find it somewhat unclear what should be returned to callback.

I’ve read the docs here:

But should the “identities” array be returned from the login function? Or should it only fill the topmost “user_id” attribute?

Some of our old users have a non-email user name. And there are some cases with multiple users having the same e-mail address registered. How will that work with Auth0 and migration? (Single Sign On). We may be able to remove the e-mail duplication but it would require some work.

We may also need to set some custom attributes on our users, e.g. roles, group id (think in terms of users belonging to the same client/company, which we need to identify), some status flags, etc. Should these be added at the root level of the returned object, or in an identity object inside the identities array? Naming restrictions?

I assume such custom attributes can be returned on sign-on, but have yet to look into it. Hints welcome.

So, should the returned object from login script look like this:

{
  "user_id": "CustomConn|123456",
  "name": "Kjell Rilbe",
  "nickname": "kjell@company.com",
  "email": "kjell@company.com",
  "email_verified": true,
  "given_name": "Kjell",
  "family_name": "Rilbe",
  "customer_id": 999888,
  "identities": [
    {
      "provider": "CustomConn",
      "user_id": "123456",
      "connection": "CustomConn",
      "isSocial": false
    }
  ]
}

Or should it look like this:

{
  "user_id": "CustomConn|123456",
  "name": "Kjell Rilbe",
  "nickname": "kjell@company.com",
  "email": "kjell@company.com",
  "email_verified": true,
  "given_name": "Kjell",
  "family_name": "Rilbe",
  "customer_id": 999888
}

And what will happen with my custom attribute “customer_id”? Will it be stored in Auth0-database or not?

When migrating, how does Auth0 know which database to store the newfound user in? I only have the custom connection and the “Username-Password-Authentication” one, but I would have thought that the latter would have to be specified as migration target somewhere…?

Hey there!

Sorry for such huge delay in response! We’re doing our best in providing you with best developer support experience out there, but sometimes our bandwidth is not enough comparing to the number of incoming questions.

Wanted to reach out to know if you still require further assistance?

We’ve managed to get our rules working, but I think the docs I’m referring could still be improved. From a quick glance, that is. Thanks!

Sure thanks a lot! Will relay that feedback to our docs team!