Check keychain every time to ensure changes propagate to extensions instantly
This commit is contained in:
parent
d28861448e
commit
dab850f311
1 changed files with 3 additions and 4 deletions
|
|
@ -11,8 +11,9 @@ 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
|
private var passcode: String? {
|
||||||
private var passcode: String? = AppKeychain.shared.get(for: PasscodeLock.identifier)
|
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() {
|
||||||
|
|
@ -28,7 +29,6 @@ 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 {
|
||||||
|
|
@ -37,6 +37,5 @@ public class PasscodeLock {
|
||||||
|
|
||||||
public func delete() {
|
public func delete() {
|
||||||
AppKeychain.shared.removeContent(for: PasscodeLock.identifier)
|
AppKeychain.shared.removeContent(for: PasscodeLock.identifier)
|
||||||
passcode = nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue