# Enable MFA based on conditions during Auth0 action

**URL:** <https://community.auth0.com/t/enable-mfa-based-on-conditions-during-auth0-action/73641>\
**Category:** Get Help\
**Tags:** mfa\
**Created:** [November 23, 2021, 2:56pm UTC](https://community.auth0.com/t/enable-mfa-based-on-conditions-during-auth0-action/73641 "2021-11-23T14:56:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gbrissonnette](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gbrissonnette/32/33192_2.png) [@gbrissonnette](https://community.auth0.com/u/gbrissonnette)\
**Post date:** [November 23, 2021, 2:56pm UTC](https://community.auth0.com/t/enable-mfa-based-on-conditions-during-auth0-action/73641/1 "2021-11-23T14:56:53Z")

</div>

Hello,

I am trying to enable MFA through an action during the authentication pipeline.  
By reading this article, it seems possible to do so:

> **[Login Flow](https://auth0.com/docs/customize/actions/flows-and-triggers/login-flow)**
>
> Learn about the Actions Login Flow and the post-login Action trigger, which is executed after a user logs in and when a Refresh Token is requested.

Here is the content of my action (at the end, I would like to add some business logic to enable or not the MFA depending of some conditions like the requested scope for instance)

```auto
exports.onExecutePostLogin = async (event, api) => {
    api.multifactor.enable("any");
};

```

I tried like this but no MFA have been requested.  
I enabled those MFA from the dashboard:

- WebAuthn with FIDO Device Biometrics
- One-time Password

And I set to `never` the `Require Multi-factor Auth` policy (because I want to ask for MFA only on specific conditions)

Thanks in advance for you help !

---

<div class="post-metadata">

**Author:** ![gbrissonnette](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/gbrissonnette/32/33192_2.png) [@gbrissonnette](https://community.auth0.com/u/gbrissonnette)\
**Post date:** [November 24, 2021, 6:56am UTC](https://community.auth0.com/t/enable-mfa-based-on-conditions-during-auth0-action/73641/2 "2021-11-24T06:56:30Z")

</div>

Oups, I think I did something wrong (like forget to publish my new pipeline flow using that actions) yesterday…

I tried it again this morning and it works like a charm.

Sorry for this false positive.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [November 24, 2021, 11:40am UTC](https://community.auth0.com/t/enable-mfa-based-on-conditions-during-auth0-action/73641/3 "2021-11-24T11:40:15Z")

</div>

No worries! We’ve all been there!

Thanks for sharing with the rest of community!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [November 25, 2021, 12:54pm UTC](https://community.auth0.com/t/enable-mfa-based-on-conditions-during-auth0-action/73641/4 "2021-11-25T12:54:48Z")

</div>


