Looking for some support on how to handle a skip for Passkey registration. We have the below action configured that we call as progressive MFA Enrollment.
const { isEnterpriseConnection } = require('actions:enterprise-connection');
const SNOOZE_DAYS = 14;
const PROMPT_EVERY_N_LOGINS = 5;
exports.onExecutePostLogin = async (event, api) => {
const FORM_ID = event.secrets.Progressive_MFA_enrollment_Form;
// Identifier First + Biometrics already completed MFA using this factor.
// Return from this Action only; later profile and token-claim Actions still run.
const completedDeviceBiometrics = event.authentication?.methods?.some(
(method) => method.name === 'webauthn-platform'
);
if (completedDeviceBiometrics) {
return;
}
const enrolledFactors = event.user.enrolledFactors || [];
const appMetadata = event.user.app_metadata || {};
const factorTypes = enrolledFactors.map((factor) => factor.type);
const hasPrimaryMfa = factorTypes.includes('phone') ||
factorTypes.includes('otp');
const hasPasskey = factorTypes.includes('webauthn-platform');
const completedPrimaryMfa = event.authentication.methods?.some(
(method) =>
method.name === 'mfa' &&
(method.type === 'phone' || method.type === 'otp')
);
const loginCount = event.stats?.logins_count || 0;
const isEverynthLogin =
loginCount > 0 &&
loginCount % PROMPT_EVERY_N_LOGINS === 0;
const snoozedUntil = appMetadata.passkey_prompt_snoozed_until ?? null;
const isSnoozed =
snoozedUntil !== null && new Date(snoozedUntil).getTime() > Date.now();
const shouldRenderForm =
hasPrimaryMfa &&
completedPrimaryMfa &&
!hasPasskey &&
(!isSnoozed || isEverynthLogin);
if (shouldRenderForm) {
api.prompt.render(FORM_ID);
}
};
exports.onContinuePostLogin = async (event, api) => {
if (isEnterpriseConnection(event)) {
return;
}
const wantsPasskey = event.prompt.fields.add_passkeymfa === 'Now';
if (wantsPasskey) {
api.authentication.enrollWith({ type: 'webauthn-platform' });
return;
}
api.user.setAppMetadata(
'passkey_prompt_snoozed_until',
new Date(
Date.now() + SNOOZE_DAYS * 24 * 60 * 60 * 1000
).toISOString()
);
};
In a nut shell, users will be prompted a custom Form to register for passkeys on their first and every 5th login and sometimes if their next login is after 14 days. Users are given an option to skip on the form with a “now” button if they want to proceed. When they select now in the form we are calling this API
api.authentication.enrollWith({ type: 'webauthn-platform' });
Atleast 50 users per week are selecting this passkey option and are failing to setup. We don’t know the actual reasons yet but thinking it could be a non supported machine or browsers causing issues.
But the real issue I want to address is, Auth0 by default is presenting a skip option on this passkey registration page, but either failling to register with a passkey or selecting the skip option is failing the authentication for the user with below error.
An MFA challenge is used in a PostLogin action but the requested factors are not properly set up. To perform MFA, enable the requested factors and ensure the user is enrolled with them.
This form is presented to users after they successfully finish MFA. So a failed login like this for a user, esp after MFA completion, is like penalising them with a bad login experience.
Any thoughts on how to handle the failure case?