Configure / implement callback after User Registration

Hi all.

I need some guidelines here please.

The application I’m working on, sends an invitation email to a person.
Then, that person clicks on the email link, and goes to the Custom Register Auth0 page. (no LOCK)

What I need to know is, if there is a way to know when the user registers himself (like a callback), so that we can trigger some actions next. i.e: add them to a specific group, etc…
(That next actions will be done in the callback page, via Auth0 API)

my best regards

You can use a rule for that. https://auth0.com/docs/rules/current

function (user, context, callback) {
  // if it is the first login (hence the `signup`)
  if (context.stats.loginsCount === 1) {

  }
  callback(null, user, context);
}

Thanks Luis.

I implemented this code below based on your suggestion:

function (user, context, callback) {

if (context.stats.loginsCount === 1) {

 context.redirect = {
    url: "https://xxxenterprise.com/xxxAuth0Login/Hook.aspx?FromAuth0=true"
};

}

callback(null, user, context);
}

But no request is arriving to my URL destiny page, after a success user registration. (checked on Users Dashboard)
Am I missing something?

Did you try debugging the rule?

function(user, context, callback) {
    if (context.stats.loginsCount === 1) {
        context.redirect = {
            url: "https://xxxenterprise.com/xxxAuth0Login/Hook.aspx?FromAuth0=true"
        };
    }
    callback(null, user, context);
}

This works fine for me. Remember this rule will only run on sign ups, so your user can’t exist in our database.

Thanks Luis.

But I still don’t get the same result as you.
Maybe I’m missing some configuration.

Here it is what I have done:

1 - First I have selected the Custom Login Form

2- Then I created the Rule we talked about.

3 - After I added that redirect URL to the Allowed Callbacks

4 - But when I try to register a user in the Signup page, the user is created in the Database but I dont get any call in my URL defined in the rule.

5 - I think the application is redirecting to the default URL on the Hostage Page

6 -Also, when I try to debug the Rule when doing the signup, I dont get any log on the Rule.

Best regards

This is the correct image for point 5

He is allways redirecting to default callback:

I think you’re confused about what is a callback url and what is the redirect rule doing. When you enable the redirect rule, here’s what happens:

  1. User signs up
  2. Auth0 creates the user
  3. Auth0 calls the rule
  4. Rule redirects to https://yourapp.com?state=TRANSACTION_STATE
  5. Your app HAS TO REDIRECT BACK TO https://your-tenant.auth0.com/continue?state=TRANSACTION_STATE *
  6. Rule finishes executing
  7. Auth0 redirects to the redirect_uri you’re using in Auth0.js

* You can also send a POST request to the /continue endpoint

The redirect rule is intercepting the authorization request, which only continues after you call the /continue endpoint.

More on this: Redirect Users from Within Rules