Handle OIDC cancellation and workaround missing progress when linking a new device. (#4935)

* Fix a bug where the link device flow wasn't dismissed when complete.

* Listen for cancellation of the WAS when linking a device (dismissing the QR screen when it happens).

* Add CustomStringConvertible conformances to QRCodeLoginScreen actions.
This commit is contained in:
Doug
2026-01-09 14:08:05 +00:00
committed by GitHub
parent 7cb472a4f7
commit a894da0903
10 changed files with 122 additions and 38 deletions
@@ -50,11 +50,7 @@ class OIDCAuthenticationPresenter: NSObject {
guard let url else {
// Check for user cancellation to avoid showing an alert in that instance.
if let nsError = error as? NSError,
nsError.domain == ASWebAuthenticationSessionErrorDomain,
nsError.code == ASWebAuthenticationSessionError.canceledLogin.rawValue,
// If there's a failure reason then the cancellation wasn't made by the user.
nsError.localizedFailureReason == nil {
if error?.isOIDCUserCancellation == true {
// No need to show an error here, just abort and return a failure.
await authenticationService.abortOIDCLogin(data: oidcData)
return .failure(.oidcError(.userCancellation))
@@ -121,3 +117,20 @@ extension ASWebAuthenticationSession.Callback {
}
}
}
// MARK: - Helpers
extension Error {
var isOIDCUserCancellation: Bool {
let nsError = self as NSError
if nsError.domain == ASWebAuthenticationSessionErrorDomain,
nsError.code == ASWebAuthenticationSessionError.canceledLogin.rawValue,
// If there's a failure reason then the cancellation wasn't made by the user.
nsError.localizedFailureReason == nil {
return true
}
return false
}
}