Skip to content

Commit

Permalink
Update useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
avatus committed Oct 24, 2024
1 parent eaf3b74 commit 5af9de6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
1 change: 0 additions & 1 deletion web/packages/teleport/src/lib/term/tty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ class Tty extends EventEmitterMfaSender {
...data.webauthn_response,
...data,
};
console.log({ data });
const encoded = this._proto.encodeChallengeResponse(
JSON.stringify(backwardCompatibleData)
);
Expand Down
11 changes: 2 additions & 9 deletions web/packages/teleport/src/lib/useMfa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,23 @@ 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) {
Expand Down

0 comments on commit 5af9de6

Please sign in to comment.