Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Joerger
Copy link
Contributor

@Joerger Joerger commented Dec 24, 2024

Changelog: Fix a bug in the WebUI for some MFA actions for users with no MFA devices, or where MFA is not required for the user.

Fix a bug caused by #49679 which was meant to check for null/undefined.

Closes #50556

@@ -69,7 +69,7 @@ export function parseMfaChallengeJson(
!challenge.webauthn_challenge &&
!challenge.totp_challenge
) {
return null;
return;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the return type of this function be MfaAuthenciateChallenge | undefined?

We don't have strict null checks enabled right now, but if we did this would not compile as-is.

@@ -282,6 +282,8 @@ const auth = {
mfaType?: DeviceType,
totpCode?: string
): Promise<MfaChallengeResponse> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps?

Suggested change
): Promise<MfaChallengeResponse> {
): Promise<MfaChallengeResponse|undefined> {

@@ -282,6 +282,8 @@ const auth = {
mfaType?: DeviceType,
totpCode?: string
): Promise<MfaChallengeResponse> {
if (!challenge) return;
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants