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!

try/catch optlib verify()

Blue Mouse627d2070999b
diff --git a/backend/apps/cloud/src/twoFactorAuth/twoFactorAuth.service.ts b/backend/apps/cloud/src/twoFactorAuth/twoFactorAuth.service.ts
index 12342dcdc..d7f773e09 100644
--- a/backend/apps/cloud/src/twoFactorAuth/twoFactorAuth.service.ts
+++ b/backend/apps/cloud/src/twoFactorAuth/twoFactorAuth.service.ts
@@ -34,11 +34,15 @@ export class TwoFactorAuthService {
if (!twoFactorAuthenticationCode) return false
if (!user?.twoFactorAuthenticationSecret) return false
- const result = await verify({
- token: twoFactorAuthenticationCode,
- secret: user.twoFactorAuthenticationSecret,
- })
-
- return result.valid
+ try {
+ const result = await verify({
+ token: twoFactorAuthenticationCode,
+ secret: user.twoFactorAuthenticationSecret,
+ })
+
+ return result.valid
+ } catch {
+ return false
+ }
}
}
diff --git a/backend/apps/community/src/twoFactorAuth/twoFactorAuth.service.ts b/backend/apps/community/src/twoFactorAuth/twoFactorAuth.service.ts
index 4d9533571..15010a8b9 100644
--- a/backend/apps/community/src/twoFactorAuth/twoFactorAuth.service.ts
+++ b/backend/apps/community/src/twoFactorAuth/twoFactorAuth.service.ts
@@ -34,11 +34,15 @@ export class TwoFactorAuthService {
if (!twoFactorAuthenticationCode) return false
if (!user?.twoFactorAuthenticationSecret) return false
- const result = await verify({
- token: twoFactorAuthenticationCode,
- secret: user.twoFactorAuthenticationSecret,
- })
-
- return result.valid
+ try {
+ const result = await verify({
+ token: twoFactorAuthenticationCode,
+ secret: user.twoFactorAuthenticationSecret,
+ })
+
+ return result.valid
+ } catch {
+ return false
+ }
}
}