# Disabling MFA using Actions not working as expected

**URL:** <https://community.auth0.com/t/disabling-mfa-using-actions-not-working-as-expected/184793>\
**Category:** Get Help\
**Tags:** extensibility, adaptive-mfa, actions-extensibility\
**Created:** [March 31, 2025, 12:19pm UTC](https://community.auth0.com/t/disabling-mfa-using-actions-not-working-as-expected/184793 "2025-03-31T12:19:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michal.k](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/michal.k/32/71179_2.png) [@michal.k](https://community.auth0.com/u/michal.k)\
**Post date:** [March 31, 2025, 12:19pm UTC](https://community.auth0.com/t/disabling-mfa-using-actions-not-working-as-expected/184793/1 "2025-03-31T12:19:39Z")

</div>

Ready to post? 🔍 First, try searching for your answer.  
Hello,

# Expectation

We would like to have Adaptive MFA configured for all users with OTP and Email as enrollment options. We would like to fully disable MFA for test users.

# Context:

1. We have enabled **Adaptive MFA** and configured OTP and Email.
2. We have a lot of automated test users, for whom we would like to **skip any mfa authentication**.
3. We have added a Post Login action “Bypass MFA for Test user”. In said action we are trying to disable the MFA  
In images below you can see how our MFA is configured.

 ![mfa_1](https://global.discourse-cdn.com/auth0/original/3X/a/6/a6bb42779bdef4bf94f58d9576ebdc33d1985aaf.png)  
 ![mfa_2](https://global.discourse-cdn.com/auth0/original/3X/8/4/8447b319b4280afadda699239c60e2f1b7a4a66f.png)  
 ![mfa_3](https://global.discourse-cdn.com/auth0/original/3X/5/d/5d16a6af8897990f55e728f86534c58a8b883d3d.png)

We have found several similar threads how to accomplish it:

1. [How to disable MFA using actions? - Auth0 Community](https://community.auth0.com/t/how-to-disable-mfa-using-actions/100687/2)
2. [How to disable mfa for a particular user - Auth0 Community](https://community.auth0.com/t/how-to-disable-mfa-for-a-particular-user/53544)
3. [Disable MFA for enterprise connection - Auth0 Community](https://community.auth0.com/t/disable-mfa-for-enterprise-connection/106790)

We followed solution 1, cause it fits best in our scenario.

# Actual result

No matter what we do, user is always prompted with MFA challenge.  
Our post-login action looks like this

```javascript
exports.onExecutePostLogin = async (event, api) => {
  api.multifactor.enable('none', {allowRememberBrowser: false});
  // api.multifactor.enable('none');
  // We tried both of options above, none worked

  (...) // logic to enable/disable mfa if needed, but we decided to try to force disabling it for everyone to see it if works
};

```

Please clarify if this can be achieved or we have misunderstood the documentation. By our findings this should have worked as expected. This is a huge blocker for us as we have a lot of automated tests running.

---

<div class="post-metadata">

**Author:** ![gerald.czifra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gerald.czifra/32/75301_2.png) [@gerald.czifra](https://community.auth0.com/u/gerald.czifra)\
**Post date:** [March 31, 2025, 8:02pm UTC](https://community.auth0.com/t/disabling-mfa-using-actions-not-working-as-expected/184793/3 "2025-03-31T20:02:27Z")

</div>

Hi @michal.k

Welcome to the Auth0 Community!

I have found that a different approach works reliably in my case while doing some testing, namely the steps outlined in our Knowledge Article on [How to Enable MFA for a Subset of Users](https://community.auth0.com/t/how-to-enable-mfa-for-a-subset-of-users/87505).  
This will operate much in the other way of your approach, in that, MFA will not be required of every user, only from those that have a specific object in their **app\_metadata** ( I would suggest setting the object in the app\_medatada instead of user\_metadata as outlined in the documentation, because users have **Read-Only** permissions to app\_medatada, but Read/Write to the latter)

Alongside the Action itself, one difference to point out would be to actually make sure that **Require Multi-factor Auth set to None**. This is because we want MFA to be triggered according to the Action, and not out-of-the-box to everyone.

From my testing, this operated the way you intended to make it work, only users with `"use_MFA" : true` object in their app\_metadata are prompted for MFA. The mentioned article also shows how to update the app\_metadata both through the Dashboard and through Management API, in case you have a larger pool of users.

The Action that I used for testing is this:

```auto
exports.onExecutePostLogin = async (event, api) => {
if (event.user.app_metadata && event.user.app_metadata.use_mfa){
api.multifactor.enable('any', {allowRememberBrowser: false});
}
};

```

Hope this helped!  
Gerald

---

<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:** [April 14, 2025, 8:03pm UTC](https://community.auth0.com/t/disabling-mfa-using-actions-not-working-as-expected/184793/4 "2025-04-14T20:03:03Z")

</div>

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