Browse Source

passcode: Only convert passcode from old setting to keychain once

Previously, the old passcode was read and set even in case the
user disabled passcode (with the new version of the app).

close #15870
David Fuhrmann 9 years ago
parent
commit
63e4267a3b
1 changed files with 7 additions and 2 deletions
  1. 7 2
      Sources/VLCKeychainCoordinator.m

+ 7 - 2
Sources/VLCKeychainCoordinator.m

@@ -79,11 +79,16 @@ NSString *const VLCPasscode = @"org.videolan.vlc-ios.passcode";
     NSString *passcode = [SSKeychain passwordForService:VLCPasscode account:VLCPasscode];
 
     if (!passcode) {
-        /* legacy passcode retrieval */
+        /* legacy passcode conversion to keychain - only do that once */
         NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
         passcode = [defaults objectForKey:kVLCSettingPasscodeKey];
-        if (passcode)
+        if (passcode && passcode.length > 0) {
+            APLog(@"Move passcode from setting to keychain");
             [self setPasscode:passcode];
+            // delete passcode from old setting
+            [defaults setObject:nil forKey:kVLCSettingPasscodeKey];
+            [defaults synchronize];
+        }
     }
 
     return passcode;