diff --git a/swift/apple/FirezoneKit/Sources/FirezoneKit/Models/WebAuthSession.swift b/swift/apple/FirezoneKit/Sources/FirezoneKit/Models/WebAuthSession.swift index 9a270c545..818ad6fcc 100644 --- a/swift/apple/FirezoneKit/Sources/FirezoneKit/Models/WebAuthSession.swift +++ b/swift/apple/FirezoneKit/Sources/FirezoneKit/Models/WebAuthSession.swift @@ -22,12 +22,14 @@ struct WebAuthSession { let anchor = PresentationAnchor() - let authResponse = try await withCheckedThrowingContinuation { continuation in + let authResponse: AuthResponse? = try await withCheckedThrowingContinuation { continuation in let session = ASWebAuthenticationSession(url: url, callbackURLScheme: scheme) { returnedURL, error in do { if let error = error as? ASWebAuthenticationSessionError, error.code == .canceledLogin { // User canceled sign in + continuation.resume(returning: nil) + return } else if let error = error { throw error } @@ -50,7 +52,9 @@ struct WebAuthSession { session.start() } - try await store.signIn(authResponse: authResponse) + if let authResponse { + try await store.signIn(authResponse: authResponse) + } } }