# Excluding users from MFA with rules breaks consent pop up

**URL:** <https://community.auth0.com/t/excluding-users-from-mfa-with-rules-breaks-consent-pop-up/93959>\
**Category:** Get Help\
**Tags:** consent, rules, mfa\
**Created:** [November 8, 2022, 2:38pm UTC](https://community.auth0.com/t/excluding-users-from-mfa-with-rules-breaks-consent-pop-up/93959 "2022-11-08T14:38:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nitzan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nitzan/32/33226_2.png) [@nitzan](https://community.auth0.com/u/nitzan)\
**Post date:** [November 8, 2022, 2:38pm UTC](https://community.auth0.com/t/excluding-users-from-mfa-with-rules-breaks-consent-pop-up/93959/1 "2022-11-08T14:38:42Z")

</div>

We added a rule that overwrites the `context.multifactor` field for users with specific user names. The exclusion itself worked as expected, but we saw an issue with the first log in of new users: after approving in the consent, the browser gets an error page.

This is the rule:

```auto
function (user, context, callback) {
  const EXCULDED_USER_PREFIXES = [
    'user1',
    'user2',
  ];
  
  if (EXCULDED_USER_PREFIXES.some(prefix => user.email.startsWith(prefix))) {
    context.multifactor = {
      provider: 'none',
    };
  }
  
  callback(null, user, context); 
}

```

This is the error message (from the logs) after the user clicks the consent approve button (reducted):

```auto
{
  "date": "2022-11-07T21:08:20.946Z",
  "type": "f",
  "description": "Unable to correlate completed consent.",
  "connection": "console-username-password-auth",
  "connection_id": " *****",
  "client_id": " *****",
  "client_name": " *****",
  "ip": " *****",
  "user_agent": "HeadlessChrome 106.0.5249 / Linux 0.0.0",
  "details": {
    "body": {},
    "qs": {
      "state": "aunPKSoGQ0ounwv8P8zeex53859HEzqP"
    },
    "connection": "console-username-password-auth",
    "error": {
      "message": "Unable to correlate completed consent.",
      "oauthError": "server_error",
      "type": "oauth-authorization"
    },
    "session_id": "Jc8r2nrfKjUFXMrQnRDF5Us08iieDAE8",
    "riskAssessment": {
      "confidence": "high",
      "version": "1",
      "assessments": {
        "UntrustedIP": {
          "confidence": "high",
          "code": "not_found_on_deny_list"
        },
        "NewDevice": {
          "confidence": "high",
          "code": "initial_login"
        },
        "ImpossibleTravel": {
          "confidence": "high",
          "code": "initial_login"
        }
      }
    },
    "actions": {
      "executions": [
        "zFw9eSvZSge2Gi9YubrK9zIwMjIxMTA3"
      ]
    }
  },
  "hostname": " *****",
  "user_id": " *****",
  "user_name": " *****",
  "strategy": "auth0",
  "strategy_type": "database",
  "organization_id": " *****",
  "organization_name": " *****",
  "audience": "https:// *****.us.auth0.com/userinfo",
  "scope": [
    "openid",
    "profile",
    "email",
    "offline_access"
  ],
  "log_id": "90020221107210823951273628476824183673115586323980222514",
  "_id": "90020221107210823951273628476824183673115586323980222514",
  "isMobile": false,
  "id": "90020221107210823951273628476824183673115586323980222514"
}

```

On subsequent logins the consent window is not shown, and there are no errors.

Is this an issue with how the rule works or a maybe a bug in the consent mechanism?

---

<div class="post-metadata">

**Author:** ![dennis.kronbuegel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dennis.kronbuegel/32/33281_2.png) [@dennis.kronbuegel](https://community.auth0.com/u/dennis.kronbuegel)\
**Post date:** [December 12, 2022, 10:20am UTC](https://community.auth0.com/t/excluding-users-from-mfa-with-rules-breaks-consent-pop-up/93959/2 "2022-12-12T10:20:37Z")

</div>

+1 Same problem here

---

<div class="post-metadata">

**Author:** ![sbriggs](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@sbriggs](https://community.auth0.com/u/sbriggs)\
**Post date:** [June 26, 2023, 10:50pm UTC](https://community.auth0.com/t/excluding-users-from-mfa-with-rules-breaks-consent-pop-up/93959/3 "2023-06-26T22:50:23Z")

</div>

+1 one this. Any remediation available? I have some users with MFA enabled and others I (as seen above) disable

---

<div class="post-metadata">

**Author:** ![mrsquish](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mrsquish/32/12951_2.png) [@mrsquish](https://community.auth0.com/u/mrsquish)\
**Post date:** [July 20, 2023, 4:56am UTC](https://community.auth0.com/t/excluding-users-from-mfa-with-rules-breaks-consent-pop-up/93959/4 "2023-07-20T04:56:13Z")

</div>

+1 For this too, bypassing MFA for SSO users.

---

<div class="post-metadata">

**Author:** ![mrsquish](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mrsquish/32/12951_2.png) [@mrsquish](https://community.auth0.com/u/mrsquish)\
**Post date:** [July 21, 2023, 4:45am UTC](https://community.auth0.com/t/excluding-users-from-mfa-with-rules-breaks-consent-pop-up/93959/5 "2023-07-21T04:45:39Z")

</div>

For those experiencing this issue, I raised a ticket and it was resolved by Thameera Senanayaka. He suggested reversing the logic, so that MFA is globally turned off and enabled in the Action, rather than the other way round. This resolved the issue for me.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 8, 2024, 8:40am UTC](https://community.auth0.com/t/excluding-users-from-mfa-with-rules-breaks-consent-pop-up/93959/6 "2024-01-08T08:40:54Z")

</div>

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