-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix useMfa error handling
#50844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix useMfa error handling
#50844
Changes from 5 commits
6de6710
bce3821
c3ad836
740e2ac
2041cb1
454a2d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ import { Cross, FingerprintSimple } from 'design/Icon'; | |
| import { guessProviderType } from 'shared/components/ButtonSso'; | ||
| import { SSOIcon } from 'shared/components/ButtonSso/ButtonSso'; | ||
|
|
||
| import { MfaState } from 'teleport/lib/useMfa'; | ||
| import { MfaCanceledError, MfaState } from 'teleport/lib/useMfa'; | ||
| import { MFA_OPTION_TOTP } from 'teleport/services/mfa'; | ||
|
|
||
| export type Props = { | ||
|
|
@@ -33,11 +33,16 @@ export type Props = { | |
| }; | ||
|
|
||
| export default function AuthnDialog({ | ||
| mfaState: { options, challenge, submit, attempt, resetAttempt }, | ||
| mfaState: { options, challenge, submit, attempt, cancelAttempt }, | ||
| replaceErrorText, | ||
| onClose, | ||
| onClose = () => {}, | ||
| }: Props) { | ||
| if (!challenge && attempt.status !== 'error') return; | ||
| const showMfaDialog = | ||
| !!challenge || | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i just want to make sure this is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I don't know why I thought it was more readable this way, updated to: |
||
| (attempt.status === 'error' && | ||
| !(attempt.error instanceof MfaCanceledError)); | ||
|
|
||
| if (!showMfaDialog) return; | ||
|
|
||
| // TODO(Joerger): TOTP should be pretty easy to support here with a small button -> form flow. | ||
| const onlyTotpAvailable = | ||
|
|
@@ -50,7 +55,7 @@ export default function AuthnDialog({ | |
| <ButtonIcon | ||
| data-testid="close-dialog" | ||
| onClick={() => { | ||
| resetAttempt(); | ||
| cancelAttempt(); | ||
| onClose(); | ||
| }} | ||
| > | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.