Skip to content

Commit

Permalink
Resolve comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joerger committed Nov 5, 2024
1 parent 0dae7ff commit 88e6c90
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion web/packages/teleterm/src/ui/ModalsHost/ModalsHost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function renderDialog(dialog: Dialog, handleClose: () => void) {
return (
<ReAuthenticate
promptMfaRequest={dialog.promptMfaRequest}
onSuccess={totpCode => {
onOtpSubmit={totpCode => {
handleClose();
dialog.onSuccess(totpCode);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const WithWebauthn = () => (
promptMfaRequest={{ ...promptMfaRequest, webauthn: true }}
onSsoContinue={() => {}}
onCancel={() => {}}
onSuccess={() => {
onOtpSubmit={() => {
window.alert(
'You somehow submitted a form while only Webauthn was available.'
);
Expand All @@ -59,7 +59,7 @@ export const WithTotp = () => (
promptMfaRequest={{ ...promptMfaRequest, totp: true }}
onSsoContinue={() => {}}
onCancel={() => {}}
onSuccess={showToken}
onOtpSubmit={showToken}
/>
</MockAppContextProvider>
);
Expand All @@ -72,13 +72,13 @@ export const WithSso = () => (
sso: {
connectorId: '',
connectorType: '',
displayName: 'Example',
displayName: 'Example SSO',
redirectUrl: '',
},
}}
onSsoContinue={() => {}}
onCancel={() => {}}
onSuccess={() => {
onOtpSubmit={() => {
window.alert(
'You somehow submitted a form while only SSO was available.'
);
Expand All @@ -97,13 +97,13 @@ export const WithWebauthnAndTotpAndSSO = () => (
sso: {
connectorId: '',
connectorType: '',
displayName: '',
displayName: 'Example SSO',
redirectUrl: '',
},
}}
onSsoContinue={() => {}}
onCancel={() => {}}
onSuccess={showToken}
onOtpSubmit={showToken}
/>
</MockAppContextProvider>
);
Expand All @@ -119,7 +119,7 @@ export const MultilineTitle = () => (
}}
onSsoContinue={() => {}}
onCancel={() => {}}
onSuccess={showToken}
onOtpSubmit={showToken}
/>
</MockAppContextProvider>
);
Expand All @@ -135,7 +135,7 @@ export const ForLeafCluster = () => (
}}
onSsoContinue={() => {}}
onCancel={() => {}}
onSuccess={showToken}
onOtpSubmit={showToken}
/>
</MockAppContextProvider>
);
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import PromptSsoStatus from 'teleterm/ui/ClusterConnect/ClusterLogin/FormLogin/P
export const ReAuthenticate: FC<{
promptMfaRequest: PromptMFARequest;
onCancel: () => void;
onSuccess: (otp: string) => void;
onOtpSubmit: (otp: string) => void;
onSsoContinue: (redirectUrl: string) => void;
}> = props => {
const { promptMfaRequest: req, onSsoContinue } = props;
Expand Down Expand Up @@ -101,7 +101,7 @@ export const ReAuthenticate: FC<{
<form
onSubmit={e => {
e.preventDefault();
validator.validate() && props.onSuccess(otpToken);
validator.validate() && props.onOtpSubmit(otpToken);
}}
>
<DialogHeader
Expand Down Expand Up @@ -207,15 +207,17 @@ function makeAvailableMfaTypes(req: PromptMFARequest): AvailableMfaType[] {
if (req.webauthn) {
availableMfaTypes.push(webauthn);
}
if (req.totp) {
availableMfaTypes.push(totp);
}
// put sso last in the list so we don't automatically open the browser unless
// sso is the only one in the list.
if (req.sso) {
availableMfaTypes.push({
value: 'sso',
label: req.sso.displayName || req.sso.connectorId,
});
}
if (req.totp) {
availableMfaTypes.push(totp);
}

// This shouldn't happen but is technically allowed by the req data structure.
if (availableMfaTypes.length === 0) {
Expand Down

0 comments on commit 88e6c90

Please sign in to comment.