'How to reset MFA in Cognito

I have a Cognito user pool which has MFA set to Required with TOTP only (i.e. no SMS). My question is how do I reset the MFA for a user? For example what if the user loses his phone so he doesn't have anyway to login.

I have tried reset password but that only resets the password, it doesn't remove the MFA.

I set up the UI(react) using the documentation below: https://docs.amplify.aws/lib/auth/mfa/q/platform/js/

Here's a piece from my code

const login = async (email, password) => {
        try {
            const user = await Auth.signIn(email, password);
                
            if (user) {
                //first time setting up the mfa, qr code is generated
                if (user.challengeName === 'MFA_SETUP') {
                    dispatch({
                        type: AUTH_RESULT_USER,
                        payload: user
                    });
                    navigate('/auth-login');
                //user added QR code to authenticator and returning back, no qr code is 
                generated in this screen"
                } else if (user.challengeName === 'SOFTWARE_TOKEN_MFA') {
                    dispatch({
                        type: AUTH_RESULT_USER,
                        payload: user
                    });
                    navigate('/auth-post-login');
                } else if (user.challengeName === 'NEW_PASSWORD_REQUIRED') {
                    const attr = user.challengeParam?.userAttributes || null;

                    if (attr) {
                        dispatch({
                            type: AUTH_RESULT_USER,
                            payload: user
                        });
                    }
                    // console.log('before', user);
                    navigate('/set-password');
                } else {
                    getUserDetails(user, user.signInUserSession.idToken.jwtToken);
                }
            }
        } catch (e) {
            console.log('error', e);

            // await logout();

            throw e;
        }
    };

What's the best way to reset the user's MFA?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source