8000 [PM-10487] Handle cancellation on setting up the PIN on Fido2 flows by fedemkr · Pull Request #801 · bitwarden/ios · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[PM-10487] Handle cancellation on setting up the PIN on Fido2 flows #801

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

Merged
merged 1 commit into from
Aug 7, 2024
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
26 changes: 16 additions & 10 deletions BitwardenShared/UI/Auth/Utilities/UserVerificationHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,24 @@ extension DefaultUserVerificationHelper: UserVerificationHelper {
return
}

userVerificationDelegate.showAlert(.enterPINCode { pin in
do {
guard !pin.isEmpty else {
throw Fido2Error.failedToSetupPin
}
userVerificationDelegate.showAlert(.enterPINCode(
onCancelled: { () in
continuation.resume(throwing: UserVerificationError.cancelled)
},
settingUp: true,
completion: { pin in
do {
guard !pin.isEmpty else {
throw Fido2Error.failedToSetupPin
}

try await self.authRepository.setPins(pin, requirePasswordAfterRestart: false)
continuation.resume()
} catch {
continuation.resume(throwing: error)
try await self.authRepository.setPins(pin, requirePasswordAfterRestart: false)
continuation.resume()
} catch {
continuation.resume(throwing: error)
}
}
})
))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,24 @@ class UserVerificationHelperTests: BitwardenTestCase { // swiftlint:disable:this
}
}

/// `setupPin()` with cancelled setup.
func test_setupPin_cancelled() async throws {
let task = Task {
try await self.subject.setupPin()
}

try await waitForAsync {
!self.userVerificationDelegate.alertShown.isEmpty
}

let alert = try XCTUnwrap(userVerificationDelegate.alertShown.last)
try await alert.tapAction(title: Localizations.cancel)

await assertAsyncThrows(error: UserVerificationError.cancelled) {
_ = try await task.value
}
}

/// `verifyDeviceLocalAuth()` with device status not authorized.
func test_verifyDeviceLocalAuth_notAuthorized() async throws {
localAuthService.deviceAuthenticationStatus = .notDetermined
Expand Down
Loading
0