From e43065e91ffef5ad38819a9cab5cc02fdfd90e3d Mon Sep 17 00:00:00 2001 From: Michael Myers Date: Thu, 24 Oct 2024 08:41:51 -0500 Subject: [PATCH] Update useEffect --- web/packages/teleport/src/lib/term/tty.ts | 1 - web/packages/teleport/src/lib/useMfa.ts | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/web/packages/teleport/src/lib/term/tty.ts b/web/packages/teleport/src/lib/term/tty.ts index 62bbca2f7c22f..85f47c897319d 100644 --- a/web/packages/teleport/src/lib/term/tty.ts +++ b/web/packages/teleport/src/lib/term/tty.ts @@ -94,7 +94,6 @@ class Tty extends EventEmitterMfaSender { ...data.webauthn_response, ...data, }; - console.log({ data }); const encoded = this._proto.encodeChallengeResponse( JSON.stringify(backwardCompatibleData) ); diff --git a/web/packages/teleport/src/lib/useMfa.ts b/web/packages/teleport/src/lib/useMfa.ts index 3c4f552696255..2ff28816525df 100644 --- a/web/packages/teleport/src/lib/useMfa.ts +++ b/web/packages/teleport/src/lib/useMfa.ts @@ -56,30 +56,24 @@ export function useMfa(emitterSender: EventEmitterMfaSender): MfaState { if (!state.ssoChallenge) { return; } - const channel = new BroadcastChannel(state.ssoChallenge.channelId); function handleMessage(e: MessageEvent<{ mfaToken: string }>) { - if (!state.ssoChallenge) { - return; - } - emitterSender.sendChallengeResponse({ sso_response: { - requestId: state.ssoChallenge.requestId, + requestId: state.ssoChallenge?.requestId, token: e.data.mfaToken, }, }); clearChallenges(); } - channel.addEventListener('message', handleMessage); return () => { channel.removeEventListener('message', handleMessage); channel.close(); }; - }, [state, emitterSender, state.ssoChallenge]); + }, [state.ssoChallenge, emitterSender]); function onSsoAuthenticate() { if (!state.ssoChallenge) {