Post Registration hook - get full user_id

Hi,

I just created a web hook for post user registration. In the user.id property I only get the GUID of the user and not the full user_id. (i.e. user_id on profile page: auth0|5d8b1128fe2e260e0d96e369, in the hook I only get the guid part (5d8b1128fe2e260e0d96e369). All after the pipeline |). Is this by design?

Is there an other way to get the full user_id field in the post registration hook?

Background:
In the id_token and access_token the sub claim use the whole user_id field (as shown in the profile page). We are using the sub claim in the token to get internal data. But if we cannot get the full user_id in the post registration we need to filter out the auth0 or text in front of the pipeline. It would be nice to know if the user are using auth0, google or other provider to signup.

Hi @tom.solem,

Welcome to the Auth0 Community Forum!

From what I understand, this behavior is due to the fact that hooks only run with database connections, and it is safe to assume that the database prefix can be used.

Hope this helps!

Thanks,
Dan

I noticed this behavior as well. Unfortunately it is not documented anywhere in the post registration user hook guide or concepts. I was able to solve my issue by checking for the presence of "auth0|" in the user.id param and prefixing it manually in my code.

Hi,

My problem was that we also uses social connector. When these are used the prefix will be “auth0|” or “google|” in the user_id based on the type authentication method selected on register. But I don’t know how to see if the user is a google user or a auth0 user. Perhaps there is a property I cannot see?

Our solution was to move the code from web hook to rules. The rules are triggered for every logon. We just fixed our code to handle this instead.

@tom.solem,

Glad you found a solution. I think my wording was a bit confusing. To clarify, you can’t use hooks with a social connection, only a db connection. This means you can assume the prefix is auth0|.

@bastula,

It took me some digging as well, I will try to reach out for clarification.

Best,
Dan

1 Like

@dan.woda
have posted a docs PR here based on the information in this thread: Update use-the-post-user-registration-extensibility-point.md by bastula · Pull Request #8281 · auth0/docs · GitHub

2 Likes

@bastula,

That’s awesome. Thanks!

Best,
Dan

1 Like

@dan.woda PR was merged and docs were updated :tada:. Hopefully this should help out other folks who run into this issue :slight_smile:

2 Likes

@bastula,

Thanks for taking the time to do that. It is very helpful for other users.

Cheers!
Dan

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.