# How can I force user to configure least 2 MFA methods or specific MFA methods

**URL:** <https://community.auth0.com/t/how-can-i-force-user-to-configure-least-2-mfa-methods-or-specific-mfa-methods/129139>\
**Category:** Get Help\
**Tags:** mfa-api, mfa\
**Created:** [March 7, 2024, 8:19am UTC](https://community.auth0.com/t/how-can-i-force-user-to-configure-least-2-mfa-methods-or-specific-mfa-methods/129139 "2024-03-07T08:19:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jun.wu](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jun.wu](https://community.auth0.com/u/jun.wu)\
**Post date:** [March 7, 2024, 8:19am UTC](https://community.auth0.com/t/how-can-i-force-user-to-configure-least-2-mfa-methods-or-specific-mfa-methods/129139/1 "2024-03-07T08:19:46Z")

</div>

RT.

If I’d like to force user to use SMS, but user was using OTP.

And `api.authentication.enrollWith` does not work when I tested in the Authentication Profile, I guess it should bring me to the page of configuring SMS, but it does nothing.

Thanks in advance.

---

<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:** [March 7, 2024, 11:20pm UTC](https://community.auth0.com/t/how-can-i-force-user-to-configure-least-2-mfa-methods-or-specific-mfa-methods/129139/3 "2024-03-07T23:20:14Z")

</div>

Hi @jun.wu,

Welcome to the Auth0 Community!

Yes, you should be able to force the user to configure at least 2 MFA methods.

One solution is to use the `api.access.deny()` method to block the user from logging in until they have configured at least 2 MFA methods.

To keep track of how many methods a user has enrolled, you can either append this information in the user\_metadata or find it by calling the Management API’s [`GET /api/v2/users/{id}/authentication-methods`](https://auth0.com/docs/api/management/v2/users/get-authentication-methods) endpoint.

I hope this helps!

Cheers,  
Rueben

---

<div class="post-metadata">

**Author:** ![jun.wu](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jun.wu](https://community.auth0.com/u/jun.wu)\
**Post date:** [March 8, 2024, 6:07am UTC](https://community.auth0.com/t/how-can-i-force-user-to-configure-least-2-mfa-methods-or-specific-mfa-methods/129139/4 "2024-03-08T06:07:42Z")

</div>

Hi @rueben.tiow ,  
thanks for your comment.

I’d like to use the customized login flow to do it.

If I’d like to navigate to enrollment page again, even user already had a MFA method.  
Is there any api could I use in Actions? Like `api.access.deny()`.

Regard,  
Jun

---

<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:** [March 8, 2024, 8:05pm UTC](https://community.auth0.com/t/how-can-i-force-user-to-configure-least-2-mfa-methods-or-specific-mfa-methods/129139/5 "2024-03-08T20:05:28Z")

</div>

Hi @jun.wu,

Yes, using the Post-Login action in your login flow should work.

Now, you won’t be able to redirect your user back to the enrollment page directly. But you can log them out so the session doesn’t stay “stuck” from being denied, and then you can allow them to reauthenticate and enroll with the other MFA factors. You will want to inform your users that they are being denied access until they have enrolled with at least 2 MFA factors.

To log them out, here is an example:

```auto
exports.onExecutePostLogin = async (event, api) => {
  if (!event.user.email_verified) {
    api.redirect.sendUserTo('https://TENANT_DOMAIN/v2/logout', {
      query: { returnTo: 'WHITELISTED_LOGOUT_URL' }
    });
  }
};

```

Cheers,  
Rueben

---

<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:** [March 22, 2024, 8:06pm UTC](https://community.auth0.com/t/how-can-i-force-user-to-configure-least-2-mfa-methods-or-specific-mfa-methods/129139/6 "2024-03-22T20:06:17Z")

</div>

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