Enable MFA based on conditions during Auth0 action

Hello,

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

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)

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 !

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.

1 Like

No worries! We’ve all been there!

Thanks for sharing with the rest of community!