Universal login page login success callback

In the universal login page using Auth0.js client-side library for authenticating the user, is there a callback for successful authentication?

There is callback for error, where we get back the error object with the message and other details when login fails due to any reason.

Code for failure Callback

webAuth.login({
          realm: realm,
          username: usernameField.value,
          password: passwordField.value,
          captcha: captcha.getValue()
        }, function (err, data) {
          console.log(err, data);

Is there a way to know that login is successful, so that we can send amplitude events for authentication success.

Did you figure this out?

There’s no callback for successful authentication, rule executes after authentication but doesnt have all the fields available.

You can add an option called onRedirecting, on webauth.login function like this

function trackLoginEvent(done) {
    //do something
    done()
}

 webAuth.login(
            {
              realm: databaseConnection,
              username: username,
              password: password,
              captcha: captcha.getValue(),
              onRedirecting: trackLoginEvent
            })