# How can I know if MFA is enabled on my app and which factors are enabled using actions?

**URL:** <https://community.auth0.com/t/how-can-i-know-if-mfa-is-enabled-on-my-app-and-which-factors-are-enabled-using-actions/86555>\
**Category:** Get Help\
**Tags:** adaptive-mfa, actions, mfa\
**Created:** [July 6, 2022, 11:00pm UTC](https://community.auth0.com/t/how-can-i-know-if-mfa-is-enabled-on-my-app-and-which-factors-are-enabled-using-actions/86555 "2022-07-06T23:00:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucas.gonzalez](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lucas.gonzalez/32/33884_2.png) [@lucas.gonzalez](https://community.auth0.com/u/lucas.gonzalez)\
**Post date:** [July 6, 2022, 11:00pm UTC](https://community.auth0.com/t/how-can-i-know-if-mfa-is-enabled-on-my-app-and-which-factors-are-enabled-using-actions/86555/1 "2022-07-06T23:00:35Z")

</div>

I’m working on an action that needs to check if the APP has MFA enabled and if there’s any factor enabled on my app.

I want to check this at the APP level, doesn’t matter if the user has enrolled in MFA yet.

Basically because if I enable MFA in my app and any factor is enabled in the dashboard, I should not enable MFA for certain users because I got an `invalid_request` with `error_description: "No Confirmed"`  
This is because I got an error if all factors are disabled.

Thanks.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [July 7, 2022, 12:00am UTC](https://community.auth0.com/t/how-can-i-know-if-mfa-is-enabled-on-my-app-and-which-factors-are-enabled-using-actions/86555/3 "2022-07-07T00:00:40Z")

</div>

Hi @lucas.gonzalez,

Welcome to the Auth0 Community!

I understand that you would like to know how to determine if your application has MFA enabled and the associated factors.

First, let me explain that when MFA is enabled, the configured MFA factors will apply to all Applications. During the enrollment stage of the authentication flow, the user will have an option to select any MFA factor that you have configured. For example, if MFA is set to **Always** , and _Phone Message_ is enabled and selected by the user, then the MFA Factor is enabled for that user.

With that, you can find which factors are enabled by navigating to your [Auth0 Dashboard \> Security \> Multi-Factor Auth](https://manage.auth0.com/#/security/mfa).

> [@lucas.gonzalez](#):
>
> Basically because if I enable MFA in my app and any factor is enabled in the dashboard, I should not enable MFA for certain users because I got an `invalid_request` with `error_description: "No Confirmed"`  
> This is because I got an error if all factors are disabled.

Yes, this is the expected behavior. You must enable at least one MFA Factor to use an Action that allows for MFA authentication, such as _Phone Message_. Then you can use an Action to enable MFA. For example:

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

```

I hope this helps!

Did I answer all of your questions?

Thank you.

---

<div class="post-metadata">

**Author:** ![lucas.gonzalez](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lucas.gonzalez/32/33884_2.png) [@lucas.gonzalez](https://community.auth0.com/u/lucas.gonzalez)\
**Post date:** [July 7, 2022, 12:19am UTC](https://community.auth0.com/t/how-can-i-know-if-mfa-is-enabled-on-my-app-and-which-factors-are-enabled-using-actions/86555/4 "2022-07-07T00:19:25Z")

</div>

@rueben.tiow Thanks for the quick answer.

This is my use case:

- Admin disables MFA for all factors
- My user has `guardian` as a multifactor option =\> [‘guardian’]

How I can check if my app has any factor enabled inside an action?

Because based on that, I’ll be able to know if I need to keep forcing MFA for those users or not.  
I want to avoid showing the `invalid_request ` error.

Something like this:

```auto
exports.onExecutePostLogin = async (event, api) => {
  if(api.multifactors.lenght != 0) {
    api.multifactor.enable('any');
  }

 // OR

  if(api.mfa == 'always) {
    api.multifactor.enable('any');
  }
};

```

Or if my user has some factor that is not enabled, force it to use one of the enabled ones.

Thanks!

---

<div class="post-metadata">

**Author:** ![lucas.gonzalez](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lucas.gonzalez/32/33884_2.png) [@lucas.gonzalez](https://community.auth0.com/u/lucas.gonzalez)\
**Post date:** [July 7, 2022, 9:43pm UTC](https://community.auth0.com/t/how-can-i-know-if-mfa-is-enabled-on-my-app-and-which-factors-are-enabled-using-actions/86555/5 "2022-07-07T21:43:49Z")

</div>

Hi @rueben.tiow

Let me know if you find something helpful,  
I ran out of ideas.

Thanks.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [July 8, 2022, 5:18pm UTC](https://community.auth0.com/t/how-can-i-know-if-mfa-is-enabled-on-my-app-and-which-factors-are-enabled-using-actions/86555/6 "2022-07-08T17:18:32Z")

</div>

Hi @lucas.gonzalez,

Thank you for your response.

> [@lucas.gonzalez](#):
>
> How I can check if my app has any factor enabled inside an action?

In this situation, I recommend using the Management API inside an Action and calling the [Retrieve Factors and their Status endpoint](https://auth0.com/docs/api/management/v2#!/Guardian/get_factors).

In the response, you should be able to see which MFA factor you have **enabled** and proceed with your logic accordingly.

Below are some helpful resources on how to do so:

- [ManagementClient getFactors()](https://auth0.github.io/node-auth0/GuardianManager.html#getFactors) method
- [How can I use the Management API in Actions?](https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947) FAQ

Please let me know how this works for you and if have any questions.

Thank you.

---

<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:** [December 22, 2022, 10:52am UTC](https://community.auth0.com/t/how-can-i-know-if-mfa-is-enabled-on-my-app-and-which-factors-are-enabled-using-actions/86555/7 "2022-12-22T10:52:27Z")

</div>


