Skip to content

Commit a1e606c

Browse files
committed
Fixes problems around holding on to the YubiKey when in background
1 parent e6bba85 commit a1e606c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Authenticator/Model/MainViewModel.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ class MainViewModel: ObservableObject {
109109
self?.isKeyPluggedIn = false
110110
self?.sessionError = error
111111
}
112+
// exit if cancelled
113+
guard !Task.isCancelled else { return }
112114
}
113115
} catch {
114116
if let sessionError = error as? OATHSessionError {
@@ -137,6 +139,9 @@ class MainViewModel: ObservableObject {
137139
isKeyPluggedIn = false
138140
sessionError = nil
139141
connectionError = nil
142+
143+
OATHSessionHandler.shared.smartCardConnection?.stop()
144+
OATHSessionHandler.shared.accessoryConnection?.stop()
140145
}
141146

142147
@MainActor private func updateAccount(_ account: Account) async {

Authenticator/Model/OATHSession.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ class OATHSessionHandler: NSObject, YKFManagerDelegate {
4848

4949
typealias ClosingCallback = ((_ error: Error?) -> Void)
5050

51-
private var nfcConnection: YKFNFCConnection?
52-
private var smartCardConnection: YKFSmartCardConnection?
53-
private var accessoryConnection: YKFAccessoryConnection?
51+
var nfcConnection: YKFNFCConnection?
52+
var smartCardConnection: YKFSmartCardConnection?
53+
var accessoryConnection: YKFAccessoryConnection?
5454

5555
private var currentSession: YKFOATHSession?
5656

0 commit comments

Comments
 (0)