Back

Is this TFA flow correct?

  • 1
  • Self Hosted
  • Auth
  • Web
✠ bode ✠
1 Oct, 2024, 23:09

Hello everyone!

I'm trying to implement TFA in my angular app, but it seems that i'm doing something wrong somewhere. Can anyone help me verify why my code ain't working? So far i have followed this flow: createMfaAuthenticator -> updateMfaAuthenticator (but the otp code is always incorrect according to appwrite) -> createMfaRecoveryCodes -> updateMFA. Here's my code:

TypeScript
generateSecret() {
        return from(this.account.createMfaAuthenticator());
    }

generateRecoveryCodes(otp: string) {
        return from(this.account.updateMfaAuthenticator(otp)).pipe(
            switchMap(() => {
                return from(this.account.createMfaRecoveryCodes());
            })
        );
    }

enable() {
        return from(this.account.updateMFA(true));
    }

Also im pretty sure there's no calling otp twice, the secret is being generated only once. That can be seen in the network tab, only one PUT otp call , the other one is an OPTIONS call. So, anybody have any ideia?

TL;DR
The developer is experiencing issues with their TFA flow implementation in an Angular app. They have followed the flow: createMfaAuthenticator -> updateMfaAuthenticator -> createMfaRecoveryCodes -> updateMFA, but the OTP code is always incorrect. They are looking for assistance in troubleshooting.
✠ bode ✠
1 Oct, 2024, 23:20
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