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

**URL:** <https://community.auth0.com/t/is-it-necessary-to-return-result-of-callback-null-user-context-in-rules/87654>\
**Category:** Get Help\
**Tags:** rules, rule\
**Created:** [July 26, 2022, 1:30pm UTC](https://community.auth0.com/t/is-it-necessary-to-return-result-of-callback-null-user-context-in-rules/87654 "2022-07-26T13:30:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sean.mclemon1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sean.mclemon1/32/33885_2.png) [@sean.mclemon1](https://community.auth0.com/u/sean.mclemon1)\
**Post date:** [July 26, 2022, 1:30pm UTC](https://community.auth0.com/t/is-it-necessary-to-return-result-of-callback-null-user-context-in-rules/87654/1 "2022-07-26T13:30:43Z")

</div>

Is it necessary to `return` when you hand over to the next callback? So in the example given [here](https://auth0.com/docs/authenticate/login/configure-silent-authentication#silent-authentication-with-multi-factor-authentication):

```auto
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?

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [July 27, 2022, 12:04am UTC](https://community.auth0.com/t/is-it-necessary-to-return-result-of-callback-null-user-context-in-rules/87654/4 "2022-07-27T00:04:31Z")

</div>

Hello @sean.mclemon1 welcome to the community!

> [@sean.mclemon1](#):
>
> 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?

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

> <https://github.com/auth0/rules/blob/83ad6bad38aa417e33155d9f7fd6561ddac439ef/src/rules/get-twitter-email.js#L25>

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [August 11, 2022, 12:04am UTC](https://community.auth0.com/t/is-it-necessary-to-return-result-of-callback-null-user-context-in-rules/87654/5 "2022-08-11T00:04:57Z")

</div>

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