Migrating MFA rule to action

Hey @dfleming !

Have you made any attempt at converting the code to an Action? We don’t have a 1:1 example per se, but here is an attempt at a conversion:

exports.onExecutePostLogin = async (event, api) => {

  const queryParmMfa = event.request.query ? event.request.query.m : "";
  let mfaProvider = "";
  const appData = event.user.app_metadata;

  if(appData && appData.mfaProvider) {
    mfaProvider = appData.mfaProvider;
  }

  if(!mfaProvider && queryParmMfa) {
    mfaProvider = queryParmMfa;
  }

  if (mfaProvider && (event.client.client_id === configuration.MFA_APP_1 || 
                      event.client.client_id === configuration.MFA_APP_2)) {
    api.multifactor.enable({
      provider: mfaProvider,
      allowRememberBrowser: true
    });
  }
};

I have not been able to test this thoroughly, but it is a place to start if you want to test yourself :slight_smile: