소스 검색

enableTouchFaceID

Marino Faggiana 1 년 전
부모
커밋
3cb5f13198

+ 2 - 2
iOSClient/AppDelegate.swift

@@ -722,7 +722,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         let passcodeViewController = TOPasscodeViewController(passcodeType: .sixDigits, allowCancel: false)
         passcodeViewController.delegate = self
         passcodeViewController.keypadButtonShowLettering = false
-        if CCUtility.getEnableTouchFaceID() && laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
+        if NCKeychain().touchFaceID, laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
             if error == nil {
                 if laContext.biometryType == .faceID {
                     passcodeViewController.biometryType = .faceID
@@ -746,7 +746,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
 
     func enableTouchFaceID() {
         guard !account.isEmpty,
-              CCUtility.getEnableTouchFaceID(),
+              NCKeychain().touchFaceID,
               NCKeychain().passcode != nil,
               NCKeychain().requestPasscodeAtStart,
               let passcodeViewController = privacyProtectionWindow?.rootViewController?.presentedViewController as? TOPasscodeViewController

+ 1 - 1
iOSClient/Settings/NCManageE2EE.swift

@@ -88,7 +88,7 @@ class NCManageE2EE: NSObject, ObservableObject, NCEndToEndInitializeDelegate, TO
         let passcodeViewController = TOPasscodeViewController(passcodeType: .sixDigits, allowCancel: true)
         passcodeViewController.delegate = self
         passcodeViewController.keypadButtonShowLettering = false
-        if CCUtility.getEnableTouchFaceID() && laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
+        if NCKeychain().touchFaceID, laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
             if error == nil {
                 if laContext.biometryType == .faceID {
                     passcodeViewController.biometryType = .faceID

+ 4 - 4
iOSClient/Settings/NCSettings.m

@@ -273,7 +273,7 @@
         [rowBloccoPasscode.cellConfig setObject:[[UIImage imageNamed:@"lock_open"] imageWithColor:UIColor.systemGrayColor size:25] forKey:@"imageView.image"];
     }
     
-    if ([CCUtility getEnableTouchFaceID]) [rowEnableTouchDaceID setValue:@1]; else [rowEnableTouchDaceID setValue:@0];
+    if ([[NCKeychain alloc] init].touchFaceID) [rowEnableTouchDaceID setValue:@1]; else [rowEnableTouchDaceID setValue:@0];
     if ([[NCKeychain alloc] init].requestPasscodeAtStart) [rowNotPasscodeAtStart setValue:@0]; else [rowNotPasscodeAtStart setValue:@1];
     if ([CCUtility getPrivacyScreenEnabled]) [rowPrivacyScreen setValue:@1]; else [rowPrivacyScreen setValue:@0];
 
@@ -301,9 +301,9 @@
     if ([rowDescriptor.tag isEqualToString:@"enableTouchDaceID"]) {
         
         if ([[rowDescriptor.value valueData] boolValue] == YES) {
-            [CCUtility setEnableTouchFaceID:true];
+            [[NCKeychain alloc] init].touchFaceID = true;
         } else {
-            [CCUtility setEnableTouchFaceID:false];
+            [[NCKeychain alloc] init].touchFaceID = false;
         }
     }
     
@@ -416,7 +416,7 @@
         passcodeViewController.delegate = self;
         passcodeViewController.keypadButtonShowLettering = false;
 
-        if (CCUtility.getEnableTouchFaceID && [laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
+        if ([[NCKeychain alloc] init].touchFaceID && [laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
             if (error == NULL) {
                 if (laContext.biometryType == LABiometryTypeFaceID) {
                     passcodeViewController.biometryType = TOPasscodeBiometryTypeFaceID;

+ 0 - 3
iOSClient/Utility/CCUtility.h

@@ -42,9 +42,6 @@
 + (void)deleteAllChainStore;
 + (void)storeAllChainInService;
 
-+ (BOOL)getEnableTouchFaceID;
-+ (void)setEnableTouchFaceID:(BOOL)set;
-
 + (NSString *)getGroupBySettings;
 + (void)setGroupBySettings:(NSString *)groupby;
 

+ 0 - 19
iOSClient/Utility/CCUtility.m

@@ -63,25 +63,6 @@
 
 #pragma ------------------------------ GET/SET
 
-+ (BOOL)getEnableTouchFaceID
-{
-    NSString *valueString = [UICKeyChainStore stringForKey:@"enableTouchFaceID" service:NCGlobal.shared.serviceShareKeyChain];
-
-    // Default TRUE
-    if (valueString == nil) {
-        [self setEnableTouchFaceID:YES];
-        return true;
-    }
-
-    return [valueString boolValue];
-}
-
-+ (void)setEnableTouchFaceID:(BOOL)set
-{
-    NSString *sSet = (set) ? @"true" : @"false";
-    [UICKeyChainStore setString:sSet forKey:@"enableTouchFaceID" service:NCGlobal.shared.serviceShareKeyChain];
-}
-
 + (NSString *)getGroupBySettings
 {
     NSString *groupby = [UICKeyChainStore stringForKey:@"groupby" service:NCGlobal.shared.serviceShareKeyChain];

+ 13 - 0
iOSClient/Utility/NCKeychain.swift

@@ -82,4 +82,17 @@ import KeychainAccess
             keychain["requestPasscodeAtStart"] = String(newValue)
         }
     }
+
+    @objc var touchFaceID: Bool {
+        get {
+            migrate(key: "enableTouchFaceID")
+            if let value = try? keychain.get("enableTouchFaceID"), let result = Bool(value) {
+                return result
+            }
+            return false
+        }
+        set {
+            keychain["enableTouchFaceID"] = String(newValue)
+        }
+    }
 }