Add the passcode cache back
This commit is contained in:
parent
4c83427a01
commit
230b421a90
2 changed files with 4 additions and 5 deletions
|
|
@ -12,11 +12,7 @@ public class PasscodeLock {
|
||||||
private static let identifier = Globals.bundleIdentifier + "passcode"
|
private static let identifier = Globals.bundleIdentifier + "passcode"
|
||||||
|
|
||||||
/// Cached passcode to avoid frequent access to Keychain
|
/// Cached passcode to avoid frequent access to Keychain
|
||||||
private var passcode: String? {
|
private var passcode: String? = AppKeychain.shared.get(for: PasscodeLock.identifier)
|
||||||
get {
|
|
||||||
AppKeychain.shared.get(for: PasscodeLock.identifier)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Constructor used to migrate passcode from SharedDefaults to Keychain
|
/// Constructor used to migrate passcode from SharedDefaults to Keychain
|
||||||
private init() {
|
private init() {
|
||||||
|
|
@ -32,6 +28,7 @@ public class PasscodeLock {
|
||||||
|
|
||||||
public func save(passcode: String) {
|
public func save(passcode: String) {
|
||||||
AppKeychain.shared.add(string: passcode, for: PasscodeLock.identifier)
|
AppKeychain.shared.add(string: passcode, for: PasscodeLock.identifier)
|
||||||
|
self.passcode = passcode
|
||||||
}
|
}
|
||||||
|
|
||||||
public func check(passcode: String) -> Bool {
|
public func check(passcode: String) -> Bool {
|
||||||
|
|
@ -40,5 +37,6 @@ public class PasscodeLock {
|
||||||
|
|
||||||
public func delete() {
|
public func delete() {
|
||||||
AppKeychain.shared.removeContent(for: PasscodeLock.identifier)
|
AppKeychain.shared.removeContent(for: PasscodeLock.identifier)
|
||||||
|
passcode = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -644,6 +644,7 @@ public class PasswordStore {
|
||||||
|
|
||||||
SharedDefaults.removeAll()
|
SharedDefaults.removeAll()
|
||||||
storeRepository = nil
|
storeRepository = nil
|
||||||
|
PasscodeLock.shared.delete() // delete the passcode cache
|
||||||
|
|
||||||
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
|
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
|
||||||
NotificationCenter.default.post(name: .passwordStoreErased, object: nil)
|
NotificationCenter.default.post(name: .passwordStoreErased, object: nil)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue