Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,16 @@
}

if let manualInputCode = viewModel.manualInputCode {
Text(manualInputCode)
.auth0TextStyle(theme.typography.helper)
.foregroundStyle(theme.colors.text.bold)
.padding(EdgeInsets(top: 10, leading: theme.spacing.sm, bottom: 10, trailing: theme.spacing.sm))
.overlay {
RoundedRectangle(cornerRadius: theme.radius.inputField)
.stroke(theme.colors.background.primary, lineWidth: 1)
}.padding(.bottom, theme.spacing.md)
if viewModel.showManualCodeText {
Text(manualInputCode)
.auth0TextStyle(theme.typography.helper)
.foregroundStyle(theme.colors.text.bold)
.padding(EdgeInsets(top: 10, leading: theme.spacing.sm, bottom: 10, trailing: theme.spacing.sm))
.overlay {
RoundedRectangle(cornerRadius: theme.radius.inputField)
.stroke(theme.colors.background.primary, lineWidth: 1)
}.padding(.bottom, theme.spacing.md)
}

Button {
#if os(macOS)
Expand Down Expand Up @@ -188,7 +190,7 @@
await viewModel.fetchEnrollmentChallenge()
}
}
.onChange(of: viewModel.navigationRoute) { _ in

Check warning on line 193 in Auth0UniversalComponents/TOTPPushEnrollment/Presentation/TOTPPushQRCodeView.swift

View workflow job for this annotation

GitHub Actions / Test on visionOS using Xcode 26.2

'onChange(of:perform:)' was deprecated in visionOS 1.0: Use `onChange` with a two or zero parameter action closure instead.
guard let route = viewModel.navigationRoute else { return }
router.navigate(to: route)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ final class TOTPPushQRCodeViewModel: ObservableObject, ErrorViewModelHandler {
@Published var qrCodeURI: String?
@Published var showLoader: Bool = true
@Published var manualInputCode: String?
@Published var showManualCodeText: Bool = false
@Published var errorViewModel: ErrorScreenViewModel?
@Published var apiCallInProgress: Bool = false
@Published var toast: Toast?
Expand Down Expand Up @@ -129,8 +130,10 @@ final class TOTPPushQRCodeViewModel: ObservableObject, ErrorViewModelHandler {
}

private func setAuthManualSetupCode() {
if let totpEnrollmentChallenge {
manualInputCode = totpEnrollmentChallenge.authenticatorManualInputCode
if totpEnrollmentChallenge.isNotNil || pushEnrollmentChallenge.isNotNil {
let manualCode: String? = totpEnrollmentChallenge?.authenticatorManualInputCode ?? pushEnrollmentChallenge?.authenticatorQRCodeURI
manualInputCode = manualCode
showManualCodeText = totpEnrollmentChallenge.isNotNil
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ struct TOTPPushQRCodeViewModelTests {
#expect(viewModel.showLoader == true)
#expect(viewModel.qrCodeURI == nil)
#expect(viewModel.manualInputCode == nil)
#expect(viewModel.showManualCodeText == false)
#expect(viewModel.errorViewModel == nil)
#expect(viewModel.apiCallInProgress == false)

Expand Down Expand Up @@ -114,6 +115,7 @@ struct TOTPPushQRCodeViewModelTests {
}
await viewModel.fetchEnrollmentChallenge()
#expect(viewModel.manualInputCode == "N47HCYSDHRKWWSLJONYEQ7LXLV5XEMC5")
#expect(viewModel.showManualCodeText == true)
}
}

Expand All @@ -126,7 +128,7 @@ struct TOTPPushQRCodeViewModelTests {
let viewModel = await TOTPPushQRCodeViewModel(
startTOTPEnrollmentUseCase: StartTOTPEnrollmentUseCase(session: makeMockSession()),
startPushEnrollmentUseCase: StartPushEnrollmentUseCase(session: makeMockSession()),
type: .totp,
type: .pushNotification,
dependencies: Auth0UniversalComponentsSDKInitializer.shared
)
await confirmation(expectedCount: 1) { @MainActor confirmation in
Expand All @@ -142,6 +144,7 @@ struct TOTPPushQRCodeViewModelTests {
}
await viewModel.fetchEnrollmentChallenge()
#expect(viewModel.qrCodeURI != nil)
#expect(viewModel.showManualCodeText == false)
}
}

Expand Down Expand Up @@ -215,6 +218,7 @@ struct TOTPPushQRCodeViewModelTests {
return (response, pushEnrollmentChallengeData)
}
await viewModel.fetchEnrollmentChallenge()
#expect(viewModel.showManualCodeText == false)
MockURLProtocol.requestHandler = { request in
let response = HTTPURLResponse(
url: request.url!,
Expand Down
Loading