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

Fix(tfa): error message for tfa code length #1843

Merged
merged 4 commits into from May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,6 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { t } from "@lingui/macro";
import { i18n } from "@lingui/core";
import { msg, t } from "@lingui/macro";
import { QrCode } from "@phosphor-icons/react";
import {
Alert,
Expand Down Expand Up @@ -46,8 +47,9 @@ import { useDialog } from "@/client/stores/dialog";

const formSchema = z.object({
uri: z.literal("").or(z.string().optional()),
// eslint-disable-next-line lingui/t-call-in-function
code: z.literal("").or(z.string().regex(/^\d{6}$/, t`Code must be exactly 6 digits long.`)),
code: z
.literal("")
.or(z.string().regex(/^\d{6}$/, i18n._(msg`Code must be exactly 6 digits long.`))),
backupCodes: z.array(z.string()),
});

Expand Down
5 changes: 4 additions & 1 deletion libs/dto/src/auth/two-factor.ts
Expand Up @@ -2,7 +2,10 @@ import { createZodDto } from "nestjs-zod/dto";
import { z } from "nestjs-zod/z";

export const twoFactorSchema = z.object({
code: z.string().length(6).regex(/^\d+$/, { message: "code must be a 6 digit number" }),
code: z
.string()
.length(6, { message: "Code must be a 6 digit number" })
.regex(/^\d+$/, { message: "Code must be a 6 digit number" }),
});

export class TwoFactorDto extends createZodDto(twoFactorSchema) {}
Expand Down