Explorar el Código

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 hace 9 años
padre
commit
63e4267a3b
Se han modificado 1 ficheros con 7 adiciones y 2 borrados
  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;