Back

MFA error for the user accounts

  • 0
  • Auth
  • Web
sokratesli
26 Mar, 2024, 13:29

Hello

I want to set up the MFA for the user accounts in JS (react) and fail repeatedly (WebSDK appwrite 14.0 with appwrite 1.5.4.).

Instructions used: https://appwrite.io/docs/products/auth/2fa

Account created with updateMFA(true);

MFA page

TypeScript
  useEffect(() => {
    const generateTOTP = async () => {
      try {
        const response = await account.get();
      } catch (error) {
        console.log(error);
        if (error.type === 'user_more_factors_required') {
            const factors = await account.listFactors();
            console.log("factors", factors)
          const { backups, secret, uri } = await account.addAuthenticator('totp');
          setBackups(backups);
          setSecret(secret);
          setUri(uri);

          const QRCode = await avatars.getQR(uri);
          setQrCode(QRCode);
          console.log(QRCode.href);
          const challenge = await account.createChallenge("totp");
          setChallengeId(challenge.$id);
        } else {
          console.error(error);
        }
      }
    };

    generateTOTP();
  }, []);

Error: TypeError: account.listFactors is not a function

Is there a good example in JS?

What am I doing wrong?

Thank you very much for your help.

TL;DR
Developers are encountering a 'TypeError: account.listFactors is not a function' error when setting up MFA for user accounts in JS (react). They followed the instructions provided in the Appwrite documentation. The error might be due to a specific version or library mismatch. Ensure you are using the correct version of WebSDK appwrite and appwrite. Double-check if 'listFactors' method is supported in the version you are using. Solution: Verify the compatibility of the versions being used and check if the 'listFactors' method is supported.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more