Store Auth0 User Reference to External DB

Hello,

I want to store the user reference once the user validates their email. So when a user clicks on the validation link in their email, I wanted to create a reference of that user to my external DB, like Auth0 ID or something.

Is there a way to achieve that?

Thanks

Hi @damand,

There are a few ways you could do this.

You can send the user ID to your own API in a Post-User Registration Hook or a Rule.

If your app only has a database connection (i.e. email/password login), you can use a Post-User Registration Hook to send the user ID to an external API.

However, the Post-User Registration Hook will only fire for database connections. If your app has multiple types of connections such as social connections (“Sign in with Google”) and a database connection (email/password), then you can use a Rule to do the same thing.

Here is an FAQ that explains how to call an external API from within a rule: How do I call my API from a rule?

Within the rule, you can make sure that the call to your API only occurs the first time a user logs in by adding this to the top of the rule:

    const count = context.stats && context.stats.loginsCount ? context.stats.loginsCount : 0;
    if (count > 1) {
        return callback(null, user, context);
    }
1 Like

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