-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add a null check to getMfaChallengeResponse
#50570
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -240,7 +240,7 @@ const auth = { | |
.then(res => { | ||
const request = { | ||
action: 'accept', | ||
webauthnAssertionResponse: res.webauthn_response, | ||
webauthnAssertionResponse: res?.webauthn_response, | ||
}; | ||
|
||
return api.put(cfg.getHeadlessSsoPath(transactionId), request); | ||
|
@@ -282,6 +282,8 @@ const auth = { | |
mfaType?: DeviceType, | ||
totpCode?: string | ||
): Promise<MfaChallengeResponse> { | ||
if (!challenge) return; | ||
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. We return undefined here, but null on line 315. Can we be more consistent and explicit about the behavior? |
||
|
||
// 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. | ||
|
@@ -439,7 +441,7 @@ const auth = { | |
return auth | ||
.getMfaChallenge({ scope, allowReuse, isMfaRequiredRequest }, abortSignal) | ||
.then(challenge => auth.getMfaChallengeResponse(challenge, 'webauthn')) | ||
.then(res => res.webauthn_response); | ||
.then(res => res?.webauthn_response); | ||
}, | ||
|
||
getMfaChallengeResponseForAdminAction(allowReuse?: boolean) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,7 @@ export function parseMfaChallengeJson( | |
!challenge.webauthn_challenge && | ||
!challenge.totp_challenge | ||
) { | ||
return null; | ||
return; | ||
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. Should the return type of this function be We don't have strict null checks enabled right now, but if we did this would not compile as-is. |
||
} | ||
|
||
// WebAuthn challenge contains Base64URL(byte) fields that needs to | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps?