Welcome to the Auth0 Community!
I am sorry about the delayed response to your inquiry!
In order to enroll a user to multiple MFAs, your action should look like this:
exports.onExecutePostLogin = async (event, api) => {
let forceEnroll = true
if (event.user.user_metadata.enrolledWithOtp === false && event.user.user_metadata.enrolledWithPhone === false) {
// already enrolled, challenge
api.authentication.challengeWithAny([{ type: 'phone'}, { type: 'otp' }]);
}
else{
api.authentication.enrollWith({type: 'otp'});
if(forceEnroll){
api.authentication.enrollWith({type: 'phone'});
}
}
}
For further information on the matter, I would recommend to review our documentation.
This way, the user will be asked to enroll to both factors when signing up or logging in or be forced to enroll in both factors.
If you have any other questions, let me know!
Kind regards