Commit 81e93935 authored by Samuel Giddins's avatar Samuel Giddins Committed by Carola Nitz

Allow killing/backgrounding the app before finishing setting a passcode

Now, we enforce that passcode is not enabled until we have finished setting a passcode
parent 6509de33
......@@ -144,12 +144,14 @@ class KeychainCoordinator: NSObject, PAPasscodeViewControllerDelegate {
}
private func passcodeFromKeychain() -> String {
if let item = try? XKKeychainGenericPasswordItem(forService: KeychainCoordinator.passcodeService, account: KeychainCoordinator.passcodeService) {
do {
let item = try XKKeychainGenericPasswordItem(forService: KeychainCoordinator.passcodeService, account: KeychainCoordinator.passcodeService)
return item.secret.stringValue
}
assert(false, "Couldn't retrieve item from Keychain! If passcodeLockEnabled we should have an item and secret")
} catch let error {
assert(false, "Couldn't retrieve item from Keychain! If passcodeLockEnabled we should have an item and secret. Error was \(error)")
return ""
}
}
// MARK: PAPassCodeDelegate
......
......@@ -130,12 +130,11 @@ NSString * const kVLCSectionTableHeaderViewIdentifier = @"VLCSectionTableHeaderV
if ([notification.object isEqual:kVLCSettingPasscodeOnKey]) {
BOOL passcodeOn = [[notification.userInfo objectForKey:kVLCSettingPasscodeOnKey] boolValue];
[self updateForPasscode:nil];
if (passcodeOn) {
PAPasscodeViewController *passcodeLockController = [[PAPasscodeViewController alloc] initForAction:PasscodeActionSet];
passcodeLockController.delegate = self;
[self presentViewController:passcodeLockController animated:YES completion:nil];
} else {
[self updateForPasscode:nil];
[self.navigationController presentViewController:passcodeLockController animated:YES completion:nil];
}
}
if ([notification.object isEqual:kVLCSettingAppTheme]) {
......@@ -191,10 +190,9 @@ NSString * const kVLCSectionTableHeaderViewIdentifier = @"VLCSectionTableHeaderV
NSError *error = nil;
[VLCKeychainCoordinator setPasscodeWithPasscode:passcode error:&error];
if (error == nil) {
if (passcode == nil) {
//Set manually the value to NO to disable the UISwitch.
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:kVLCSettingPasscodeOnKey];
}
//Set manually the value to enable/disable the UISwitch.
BOOL passcodeEnabled = passcode != nil;
[[NSUserDefaults standardUserDefaults] setBool:passcodeEnabled forKey:kVLCSettingPasscodeOnKey];
[self updateUIAndCoreSpotlightForPasscodeSetting:passcode != nil];
}
if ([self.navigationController.presentedViewController isKindOfClass:[PAPasscodeViewController class]]) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment