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,11 +144,13 @@ class KeychainCoordinator: NSObject, PAPasscodeViewControllerDelegate { ...@@ -144,11 +144,13 @@ class KeychainCoordinator: NSObject, PAPasscodeViewControllerDelegate {
} }
private func passcodeFromKeychain() -> String { private func passcodeFromKeychain() -> String {
if let item = try? XKKeychainGenericPasswordItem(forService: KeychainCoordinator.passcodeService, account: KeychainCoordinator.passcodeService) { do {
return item.secret.stringValue 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 "" return ""
}
} }
// MARK: PAPassCodeDelegate // MARK: PAPassCodeDelegate
......
...@@ -130,12 +130,11 @@ NSString * const kVLCSectionTableHeaderViewIdentifier = @"VLCSectionTableHeaderV ...@@ -130,12 +130,11 @@ NSString * const kVLCSectionTableHeaderViewIdentifier = @"VLCSectionTableHeaderV
if ([notification.object isEqual:kVLCSettingPasscodeOnKey]) { if ([notification.object isEqual:kVLCSettingPasscodeOnKey]) {
BOOL passcodeOn = [[notification.userInfo objectForKey:kVLCSettingPasscodeOnKey] boolValue]; BOOL passcodeOn = [[notification.userInfo objectForKey:kVLCSettingPasscodeOnKey] boolValue];
[self updateForPasscode:nil];
if (passcodeOn) { if (passcodeOn) {
PAPasscodeViewController *passcodeLockController = [[PAPasscodeViewController alloc] initForAction:PasscodeActionSet]; PAPasscodeViewController *passcodeLockController = [[PAPasscodeViewController alloc] initForAction:PasscodeActionSet];
passcodeLockController.delegate = self; passcodeLockController.delegate = self;
[self presentViewController:passcodeLockController animated:YES completion:nil]; [self.navigationController presentViewController:passcodeLockController animated:YES completion:nil];
} else {
[self updateForPasscode:nil];
} }
} }
if ([notification.object isEqual:kVLCSettingAppTheme]) { if ([notification.object isEqual:kVLCSettingAppTheme]) {
...@@ -191,10 +190,9 @@ NSString * const kVLCSectionTableHeaderViewIdentifier = @"VLCSectionTableHeaderV ...@@ -191,10 +190,9 @@ NSString * const kVLCSectionTableHeaderViewIdentifier = @"VLCSectionTableHeaderV
NSError *error = nil; NSError *error = nil;
[VLCKeychainCoordinator setPasscodeWithPasscode:passcode error:&error]; [VLCKeychainCoordinator setPasscodeWithPasscode:passcode error:&error];
if (error == nil) { if (error == nil) {
if (passcode == nil) { //Set manually the value to enable/disable the UISwitch.
//Set manually the value to NO to disable the UISwitch. BOOL passcodeEnabled = passcode != nil;
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:kVLCSettingPasscodeOnKey]; [[NSUserDefaults standardUserDefaults] setBool:passcodeEnabled forKey:kVLCSettingPasscodeOnKey];
}
[self updateUIAndCoreSpotlightForPasscodeSetting:passcode != nil]; [self updateUIAndCoreSpotlightForPasscodeSetting:passcode != nil];
} }
if ([self.navigationController.presentedViewController isKindOfClass:[PAPasscodeViewController class]]) { 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