Remove keychain password with profile removal

This commit is contained in:
Davide De Rosa 2018-11-02 15:43:44 +01:00
parent b051f8118f
commit f75fbfb4bb
2 changed files with 14 additions and 2 deletions

View File

@ -72,4 +72,11 @@ extension ConnectionProfile {
}
try keychain.set(password: password, for: key, label: key)
}
func removePassword(in keychain: Keychain) {
guard let key = passwordKey else {
return
}
keychain.removePassword(for: key)
}
}

View File

@ -395,10 +395,11 @@ class ConnectionService: Codable {
}
func removeProfile(_ key: ProfileKey) {
guard let i = cache.index(forKey: key) else {
guard let profile = cache[key] else {
return
}
cache.remove(at: i)
cache.removeValue(forKey: key)
removeCredentials(for: profile)
pendingRemoval.insert(key)
if cache.isEmpty {
activeProfileKey = nil
@ -458,6 +459,10 @@ class ConnectionService: Codable {
try profile.setPassword(credentials?.password, in: keychain)
}
func removeCredentials(for profile: ConnectionProfile) {
profile.removePassword(in: keychain)
}
// MARK: VPN
func vpnConfiguration() throws -> NetworkExtensionVPNConfiguration {