'Can you change user.challengeName in Amplify

I'm trying to give the end-user an option on the UI to reset MFA if the end-user loses access to the device they've been using.

I want to change the user.challangeName response from "SOFTWARE_TOKEN_MFA" to "MFA_SETUP". Is this something that can be done? Can I change the challangeName through UI?

Code here

 const login = async (email, password) => {
        try {
            const user = await Auth.signIn(email, password);

            if (user) {
                if (user.challengeName === 'MFA_SETUP') {
                    dispatch({
                        type: AUTH_RESULT_USER,
                        payload: user
                    });
                    navigate('/auth-login');
                } 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;
        }
    };


Sources

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

Source: Stack Overflow

Solution Source