Is it necessary to return result of callback(null, user, context) in rules

Is it necessary to return when you hand over to the next callback? So in the example given here:

function (user, context, callback) {
  let authMethods = [];
  if (context.authentication && Array.isArray(context.authentication.methods)) {
    authMethods = context.authentication.methods;
  }

  const completedMfa = !!authMethods.find((method) => method.name === 'mfa');

  if (completedMfa) {
    return callback(null, user, context);
  }

  context.multifactor = {
    provider: 'any',
    allowRememberBrowser: false
  };

  callback(null, user, context);
}

The first call to callback(null, user, context) is return-ed, but the second isn’t. Is there any reason for this, or is it just used to avoid executing the rest of the rule? Is there any use of that returned value that we should be aware of?

Hello @sean.mclemon1 welcome to the community!

Good question! It looks to me like it is used to just stop execution, here’s another rule for example:

1 Like

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