Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Two-Factor Authentication (2FA) Setup Verification Zod Message is incorrect #1831

Open
1 task done
lplawlor opened this issue Mar 27, 2024 · 5 comments
Open
1 task done
Assignees
Labels
bug Something isn't working needs triage Issues that need to be triaged v4 Issues related to the latest version

Comments

@lplawlor
Copy link

Is there an existing issue for this?

  • Yes, I have searched the existing issues and none of them match my problem.

Product Variant

Cloud (http://rxresu.me)

Current Behavior

Upon setting up a TOTP device, you must "Enter the 6-digit code from your authenticator app to verify that 2FA has been setup correctly." However, if you submit an incorrect code, the message displayed in the FormMessage component is a strange 6-character string.

As an example, I created a dummy account and put in just the first 5 digits of the 2FA code (I've since deleted the account so this screenshot isn't at risk of revealing anything sensitive.)
image

Expected Behavior

The error message should read "Code must be exactly 6 digits long.", as defined in the Zod schema.

Steps To Reproduce

  1. Go to User settings while logged-in
  2. Disable 2FA (if already enabled).
  3. Click "Enable 2FA"
  4. Setup your TOTP device.
  5. Enter an incorrect code into the "Code" field on the dialogue which reads "Enter the 6-digit code from your authenticator app to verify that 2FA has been setup correctly."

What browsers are you seeing the problem on?

Firefox

What template are you using?

None

Anything else?

I've had a glance over the associated Zod schema. The only thing I see that might be causing this bug is the usage of the Lingui translate macro t. It's worth noting that the t-call-in-function ESLint rule is being ignored for this line of the Zod schema, which may be producing strange behaviour.

@lplawlor lplawlor added bug Something isn't working needs triage Issues that need to be triaged v4 Issues related to the latest version labels Mar 27, 2024
@abizek
Copy link
Contributor

abizek commented Apr 2, 2024

I tried to recreate but I am getting this

Screenshot from 2024-04-02 12-15-41

Although, it could happen since the error message is not passed for the length check.

.length(6)
.regex(/^[0-9]+$/, { message: "code must be a 6 digit number" }),

@lplawlor
Copy link
Author

lplawlor commented Apr 2, 2024

Hey, I don't think that's the same form / Zod schema as the one I experienced the bug with.

It seems to only be present in the form for verifying the 2FA code the very first time.

There's a link in my original post to the Zod schema in question. It uses a custom regex rather than a .length(6) call.

@abizek
Copy link
Contributor

abizek commented Apr 2, 2024

Oh, you mean this guy?

code: z.literal("").or(z.string().regex(/^\d{6}$/, t`Code must be exactly 6 digits long.`)),

My bad.

@lplawlor
Copy link
Author

lplawlor commented Apr 2, 2024

Yeah that's the one. No worries!

@abizek
Copy link
Contributor

abizek commented Apr 2, 2024

This happens only on https://rxresu.me, I cannot recreate it even in a production build locally, but as per Lingui docs, a lazy translation should solve the issue here without using t. The lazy translation works on a production build I ran locally, but we'll have to deploy it and see if it works on https://rxresu.me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Issues that need to be triaged v4 Issues related to the latest version
Projects
None yet
Development

No branches or pull requests

3 participants