# Allow user to setup MFA if not yet setup

**URL:** <https://community.auth0.com/t/allow-user-to-setup-mfa-if-not-yet-setup/121024>\
**Category:** Get Help\
**Tags:** mfa-prompt-new-experience, mfa\
**Created:** [November 16, 2023, 11:49am UTC](https://community.auth0.com/t/allow-user-to-setup-mfa-if-not-yet-setup/121024 "2023-11-16T11:49:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anil.babu](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@anil.babu](https://community.auth0.com/u/anil.babu)\
**Post date:** [November 16, 2023, 11:49am UTC](https://community.auth0.com/t/allow-user-to-setup-mfa-if-not-yet-setup/121024/1 "2023-11-16T11:49:43Z")

</div>

Hi Team,

I am trying to enable MFA for a specific Client ID, code looks something like this:

```auto

exports.onExecutePostLogin = async (event, api) => {
	const CLIENTS_WITH_MFA = [ <myClientIdList>
	];

	if (CLIENTS_WITH_MFA.includes(event.client.client_id)) {
		api.multifactor.enable('any', { allowRememberBrowser: false })
	}
}

```

However, if a user has not yet already registered for the MFA, we need the ability to allow the user to configure the MFA. Can you please help us understand:

1. how can we check if the user is enabled for MFA or not
2. how can we allow the user to register for MFA post login, if he/she has not yet configured?

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:** [November 16, 2023, 10:38pm UTC](https://community.auth0.com/t/allow-user-to-setup-mfa-if-not-yet-setup/121024/3 "2023-11-16T22:38:50Z")

</div>

Hi @anil.babu,

Welcome to the Auth0 Community!

> [@anil.babu](#):
>
> how can we check if the user is enabled for MFA or not

You can check the `event.user.multifactor` property to see if the user has MFA enrolled. If so, you should see an array of the MFA factors currently enrolled.

> [@anil.babu](#):
>
> - how can we allow the user to register for MFA post login, if he/she has not yet configured?

You can check if the user has any MFA factors currently enrolled. If the user has no MFA factors enrolled then allow the user to enroll MFA.  
For example:

```auto
if(!event.user.multifactor){
  api.multifactor.enable('any', { allowRememberBrowser: false})
}

```

I hope this helps!

Thanks,  
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:** [November 30, 2023, 10:39pm UTC](https://community.auth0.com/t/allow-user-to-setup-mfa-if-not-yet-setup/121024/4 "2023-11-30T22:39:14Z")

</div>

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