I am trying to customize a login flow into dashboard using post login action
exports.onExecutePostLogin = async (event, api) => {
if (event.user.enrolledFactors?.length) {
// already enrolled, challenge
api.authentication.challengeWithAny(event.user.enrolledFactors.map(m => ({type: m.type})));
}
else {
// not enrolled; choose a factor to enroll now
api.authentication.enrollWithAny([{type: 'email'}, {type: 'otp'}]);
}
api.authentication.challengeWithAny([{type: 'email'}, {type: 'otp'}]);
};
But i am receiving the following error
{"message":"invalid_request (MFA customized via PostLogin action but feature is not enabled.)","errorCode":500}
My MFA are enabled in dashboard