Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix: 2FA recovery code is rejected

Blue Mouse72a35ce36df1
diff --git a/backend/apps/cloud/src/twoFactorAuth/dto/2fa-auth.dto.ts b/backend/apps/cloud/src/twoFactorAuth/dto/2fa-auth.dto.ts
index 7f9cbcb53..703fd63ec 100644
--- a/backend/apps/cloud/src/twoFactorAuth/dto/2fa-auth.dto.ts
+++ b/backend/apps/cloud/src/twoFactorAuth/dto/2fa-auth.dto.ts
@@ -5,6 +5,6 @@ export class TwoFactorAuthDTO {
@ApiProperty({ example: '123456', required: true })
@IsNotEmpty()
@IsString()
- @Matches(/^\d{6}$/)
+ @Matches(/^[a-zA-Z0-9]{6,30}$/)
twoFactorAuthenticationCode: string
}
diff --git a/backend/apps/community/src/twoFactorAuth/dto/2fa-auth.dto.ts b/backend/apps/community/src/twoFactorAuth/dto/2fa-auth.dto.ts
index 7f9cbcb53..703fd63ec 100644
--- a/backend/apps/community/src/twoFactorAuth/dto/2fa-auth.dto.ts
+++ b/backend/apps/community/src/twoFactorAuth/dto/2fa-auth.dto.ts
@@ -5,6 +5,6 @@ export class TwoFactorAuthDTO {
@ApiProperty({ example: '123456', required: true })
@IsNotEmpty()
@IsString()
- @Matches(/^\d{6}$/)
+ @Matches(/^[a-zA-Z0-9]{6,30}$/)
twoFactorAuthenticationCode: string
}
diff --git a/web/app/routes/login.tsx b/web/app/routes/login.tsx
index a78937be5..6e0c18e6e 100644
--- a/web/app/routes/login.tsx
+++ b/web/app/routes/login.tsx
@@ -69,11 +69,13 @@ export async function action({ request }: ActionFunctionArgs) {
if (
!twoFactorAuthenticationCode ||
- twoFactorAuthenticationCode.length !== 6
+ !/^[a-zA-Z0-9]{6,30}$/.test(twoFactorAuthenticationCode)
) {
return data<LoginActionData>(
{
- fieldErrors: { twoFACode: 'Please enter a valid 6-digit code' },
+ fieldErrors: {
+ twoFACode: 'Please enter a valid 2FA or recovery code',
+ },
timestamp: Date.now(),
},
{ status: 400 },