Ver código fonte

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 anos atrás
pai
commit
63e4267a3b
1 arquivos alterados com 7 adições e 2 exclusões
  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;