diff --git a/FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/SignedInView.swift b/FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/SignedInView.swift index cb886ddd0f..e996ccc5b3 100644 --- a/FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/SignedInView.swift +++ b/FirebaseSwiftUI/FirebaseAuthSwiftUI/Sources/Views/SignedInView.swift @@ -75,17 +75,19 @@ extension SignedInView: View { .frame(maxWidth: .infinity) .accessibilityIdentifier("update-password-button") - Button { - authService.navigator.push(.mfaManagement) - } label: { - Text(authService.string.manageTwoFactorAuthenticationLabel) - .padding(.vertical, 8) - .frame(maxWidth: .infinity) + if authService.configuration.mfaEnabled { + Button { + authService.navigator.push(.mfaManagement) + } label: { + Text(authService.string.manageTwoFactorAuthenticationLabel) + .padding(.vertical, 8) + .frame(maxWidth: .infinity) + } + .buttonStyle(.borderedProminent) + .padding([.top, .bottom], 8) + .frame(maxWidth: .infinity) + .accessibilityIdentifier("mfa-management-button") } - .buttonStyle(.borderedProminent) - .padding([.top, .bottom], 8) - .frame(maxWidth: .infinity) - .accessibilityIdentifier("mfa-management-button") Button { showDeleteConfirmation = true diff --git a/e2eTest/FirebaseSwiftUIExample/FirebaseSwiftUIExampleUITests/FirebaseSwiftUIExampleUITests.swift b/e2eTest/FirebaseSwiftUIExample/FirebaseSwiftUIExampleUITests/FirebaseSwiftUIExampleUITests.swift index 70fccea74b..bc55aa202f 100644 --- a/e2eTest/FirebaseSwiftUIExample/FirebaseSwiftUIExampleUITests/FirebaseSwiftUIExampleUITests.swift +++ b/e2eTest/FirebaseSwiftUIExample/FirebaseSwiftUIExampleUITests/FirebaseSwiftUIExampleUITests.swift @@ -156,6 +156,12 @@ final class FirebaseSwiftUIExampleUITests: XCTestCase { "SignedInView should be visible after login" ) + let mfaManagementButton = app.buttons["mfa-management-button"] + XCTAssertFalse( + mfaManagementButton.exists, + "MFA management button should be hidden when MFA is disabled" + ) + dismissAlert(app: app) // Check the Views are updated let signOutButton = app.buttons["sign-out-button"]