From f0ef11eec4c73ad6bb97a012a7fde880f36ca231 Mon Sep 17 00:00:00 2001 From: Johannes Schliephake Date: Sat, 13 Feb 2021 16:41:10 +0100 Subject: [PATCH] Clear keychain only when launching app for the first time --- Shared/Utilities/Keychain.swift | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Shared/Utilities/Keychain.swift b/Shared/Utilities/Keychain.swift index 061feefc..dc0ab12e 100644 --- a/Shared/Utilities/Keychain.swift +++ b/Shared/Utilities/Keychain.swift @@ -14,15 +14,17 @@ final class Keychain { self.accessGroup = accessGroup /// This section will be improved in a future version - if load(key: "clearKeychain") == nil { + if !Configuration.userDefaults.bool(forKey: "appDidLaunch") { Configuration.userDefaults.set(true, forKey: "appDidLaunch") - store(key: "clearKeychain", value: "true") - } - else if !Configuration.userDefaults.bool(forKey: "appDidLaunch") { - remove(key: "server") - remove(key: "user") - remove(key: "password") - remove(key: "acceptedCertificateHash") + if load(key: "clearKeychain") == nil { + store(key: "clearKeychain", value: "true") + } + else { + remove(key: "server") + remove(key: "user") + remove(key: "password") + remove(key: "acceptedCertificateHash") + } } }