imports/vx/server/code/vxapp.js
/**
     * Disable 2FA on behalf of either the current user or a specified user.
     *
     * @param {string} userId Optional user ID.
     * @return {object} Standard result object.
     */
Disable 2FA on behalf of either the current user or a specified user.
@param {string} userId Optional user ID.
@return {object} Standard result object.
Disable 2FA on behalf of either the current user or a specified user . @param { string } userId Optional user ID . @return { object } Standard result object .
disableTwoFactor(userId) {
        try {
            if (userId && !Util.isUserAdmin(Meteor.userId())) {
                OLog.error(`vxapp.js disableTwoFactor security check failed userId supplied but invoking user ${Util.fetchFullName(Meteor.userId())} is not an administrator`)
                return { success : false, icon : "EYE", key : "common.alert_security_check_failed" }
            }
            userId = userId || Meteor.userId()
            const user = Util.fetchUserLimited(Meteor.userId())
            if (!user) {
                OLog.error(`vxapp.js disableTwoFactor unable to find userId=${userId}`)
                return { success: false, icon: "BUG", key: "common.alert_transaction_fail_user_not_found", variables: { userId: userId } }
            }
            const modifier = {}
            modifier.$unset = {}
            modifier.$unset.twoFactorEnabled = ""
            modifier.$unset["services.twoFactorSecret"] = ""
            Meteor.users.update(userId, modifier)
            OLog.debug(`vxapp.js disableTwoFactor ${Util.getUserEmail(user)} *disabled*`)
            return { success : true, type : "INFO", icon : "RETIRE", key : "common.alert_2fa_disabled" }
        }
        catch (error) {
            OLog.error(`vxapp.js disableTwoFactor unexpected error=${error}`)
            return { success : false, icon : "BUG", key : "common.alert_unexpected_error", variables : { error : error.toString() } }
        }
    }
disableTwoFactor ( userId ) { try { if ( userId && ! Util . isUserAdmin ( Meteor . userId ( ) ) ) { OLog . error ( ` ${ Util . fetchFullName ( Meteor . userId ( ) ) } ` ) return { success : false , icon : "EYE" , key : "common.alert_security_check_failed" } } userId = userId || Meteor . userId ( ) const user = Util . fetchUserLimited ( Meteor . userId ( ) ) if ( ! user ) { OLog . error ( ` ${ userId } ` ) return { success : false , icon : "BUG" , key : "common.alert_transaction_fail_user_not_found" , variables : { userId : userId } } } const modifier = { } modifier . $unset = { } modifier . $unset . twoFactorEnabled = "" modifier . $unset [ "services.twoFactorSecret" ] = "" Meteor . users . update ( userId , modifier ) OLog . debug ( ` ${ Util . getUserEmail ( user ) } ` ) return { success : true , type : "INFO" , icon : "RETIRE" , key : "common.alert_2fa_disabled" } } catch ( error ) { OLog . error ( ` ${ error } ` ) return { success : false , icon : "BUG" , key : "common.alert_unexpected_error" , variables : { error : error . toString ( ) } } } }
Disable 2FA on behalf of either the current user or a specified user.
Disable 2FA on behalf of either the current user or a specified user .