浏览代码

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 年之前
父节点
当前提交
63e4267a3b
共有 1 个文件被更改,包括 7 次插入2 次删除
  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;