From e6b64f91b321095b09b1d0a049cf1ca2f3cf85c5 Mon Sep 17 00:00:00 2001 From: joerger Date: Tue, 24 Dec 2024 10:49:50 -0800 Subject: [PATCH] Add a null check to getMfaChallengeResponse. --- web/packages/teleport/src/services/auth/auth.ts | 2 ++ web/packages/teleport/src/services/mfa/makeMfa.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/web/packages/teleport/src/services/auth/auth.ts b/web/packages/teleport/src/services/auth/auth.ts index 6480e41931ff2..7e525ff0819e3 100644 --- a/web/packages/teleport/src/services/auth/auth.ts +++ b/web/packages/teleport/src/services/auth/auth.ts @@ -282,6 +282,8 @@ const auth = { mfaType?: DeviceType, totpCode?: string ): Promise { + if (!challenge) return; + // TODO(Joerger): If mfaType is not provided by a parent component, use some global context // to display a component, similar to the one used in useMfa. For now we just default to // whichever method we can succeed with first. diff --git a/web/packages/teleport/src/services/mfa/makeMfa.ts b/web/packages/teleport/src/services/mfa/makeMfa.ts index 505a972fe33e5..03fb1fa65a9c2 100644 --- a/web/packages/teleport/src/services/mfa/makeMfa.ts +++ b/web/packages/teleport/src/services/mfa/makeMfa.ts @@ -69,7 +69,7 @@ export function parseMfaChallengeJson( !challenge.webauthn_challenge && !challenge.totp_challenge ) { - return null; + return; } // WebAuthn challenge contains Base64URL(byte) fields that needs to