Commit e7b9cf3e authored by Carola Nitz's avatar Carola Nitz

VLCKeychainCoordinator: don't reset passcode on update

That led to not showing the screen after initially setting a passcode.
Additionally resetting _avoidPromptingTouchID in completionblock avoids double showing
of the Touch id prompt
parent e3f63bed
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#define kVLCVersionCodename @"All Along the Watchtower" #define kVLCVersionCodename @"All Along the Watchtower"
#define kVLCSettingPasscodeResetOnUpgrade @"kVLCSettingPasscodeResetOnUpgrade"
#define kVLCSettingPasscodeOnKey @"PasscodeProtection" #define kVLCSettingPasscodeOnKey @"PasscodeProtection"
#define kVLCSettingPasscodeAllowTouchID @"AllowTouchID" #define kVLCSettingPasscodeAllowTouchID @"AllowTouchID"
#define kVLCAutomaticallyPlayNextItem @"AutomaticallyPlayNextItem" #define kVLCAutomaticallyPlayNextItem @"AutomaticallyPlayNextItem"
......
...@@ -65,20 +65,11 @@ NSString *const VLCPasscode = @"org.videolan.vlc-ios.passcode"; ...@@ -65,20 +65,11 @@ NSString *const VLCPasscode = @"org.videolan.vlc-ios.passcode";
} }
} }
- (NSString *)_obtainPasscode - (NSString *)passcodeFromKeychain
{ {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; XKKeychainGenericPasswordItem *item = [XKKeychainGenericPasswordItem itemForService:VLCPasscode account:VLCPasscode error:nil];
BOOL wasReset = [defaults boolForKey:kVLCSettingPasscodeResetOnUpgrade]; NSString *passcode = item.secret.stringValue;
if (wasReset) { return passcode;
XKKeychainGenericPasswordItem *item = [XKKeychainGenericPasswordItem itemForService:VLCPasscode account:VLCPasscode error:nil];
NSString *passcode = item.secret.stringValue;
return passcode;
}
[XKKeychainGenericPasswordItem removeItemsForService:VLCPasscode error:nil];
[defaults setBool:YES forKey:kVLCSettingPasscodeResetOnUpgrade];
return nil;
} }
- (BOOL)touchIDEnabled - (BOOL)touchIDEnabled
...@@ -93,15 +84,9 @@ NSString *const VLCPasscode = @"org.videolan.vlc-ios.passcode"; ...@@ -93,15 +84,9 @@ NSString *const VLCPasscode = @"org.videolan.vlc-ios.passcode";
- (void)validatePasscodeWithCompletion:(void(^)(void))completion - (void)validatePasscodeWithCompletion:(void(^)(void))completion
{ {
NSString *passcode = [self _obtainPasscode];
if (passcode == nil || [passcode isEqualToString:@""]) {
completion();
return;
}
_passcodeLockController = [[PAPasscodeViewController alloc] initForAction:PasscodeActionEnter]; _passcodeLockController = [[PAPasscodeViewController alloc] initForAction:PasscodeActionEnter];
_passcodeLockController.delegate = self; _passcodeLockController.delegate = self;
_passcodeLockController.passcode = passcode; _passcodeLockController.passcode = [self passcodeFromKeychain];
_completion = completion; _completion = completion;
UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController; UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
...@@ -121,7 +106,7 @@ NSString *const VLCPasscode = @"org.videolan.vlc-ios.passcode"; ...@@ -121,7 +106,7 @@ NSString *const VLCPasscode = @"org.videolan.vlc-ios.passcode";
- (void)_touchIDQuery - (void)_touchIDQuery
{ {
//if we just entered background don't show TouchID //if we just entered background don't show TouchID
if (_avoidPromptingTouchID || [UIApplication sharedApplication].applicationState == UIApplicationStateInactive) if (_avoidPromptingTouchID || [UIApplication sharedApplication].applicationState != UIApplicationStateActive)
return; return;
LAContext *myContext = [[LAContext alloc] init]; LAContext *myContext = [[LAContext alloc] init];
...@@ -132,12 +117,15 @@ NSString *const VLCPasscode = @"org.videolan.vlc-ios.passcode"; ...@@ -132,12 +117,15 @@ NSString *const VLCPasscode = @"org.videolan.vlc-ios.passcode";
reply:^(BOOL success, NSError *error) { reply:^(BOOL success, NSError *error) {
//if we cancel we don't want to show TouchID again //if we cancel we don't want to show TouchID again
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
_avoidPromptingTouchID = !success;
if (success) { if (success) {
[[UIApplication sharedApplication].delegate.window.rootViewController dismissViewControllerAnimated:YES completion:^{ [[UIApplication sharedApplication].delegate.window.rootViewController dismissViewControllerAnimated:YES completion:^{
_completion(); _completion();
_completion = nil; _completion = nil;
_avoidPromptingTouchID = NO;
}]; }];
} else {
//user hit cancel and wants to enter the passcode
_avoidPromptingTouchID = YES;
} }
}); });
}]; }];
......
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