marinofaggiana 4 years ago
parent
commit
7316227f43
2 changed files with 39 additions and 1 deletions
  1. 38 0
      iOSClient/Settings/CCSettings.m
  2. 1 1
      iOSClient/Settings/NCManageEndToEndEncryption.m

+ 38 - 0
iOSClient/Settings/CCSettings.m

@@ -319,6 +319,23 @@
 
 #pragma mark - Passcode -
 
+- (void)didPerformBiometricValidationRequestInPasscodeViewController:(TOPasscodeViewController *)passcodeViewController
+{
+    LAContext *laContext = [[LAContext alloc] init];
+
+    [laContext evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"" reply:^(BOOL success, NSError * _Nullable error) {
+
+        if (error != NULL) {
+            // handle error
+        } else if (success) {
+            [CCUtility setBlockCode:@""];
+            [self reloadForm];
+        } else {
+            // handle false response
+        }
+    }];
+}
+
 - (void)passcodeSettingsViewController:(TOPasscodeSettingsViewController *)passcodeSettingsViewController didChangeToNewPasscode:(NSString *)passcode ofType:(TOPasscodeType)type
 {
     [CCUtility setBlockCode:passcode];
@@ -346,6 +363,9 @@
 
 - (void)passcode:(XLFormRowDescriptor *)sender
 {
+    LAContext *laContext = [[LAContext alloc] init];
+    NSError *error;
+    
     [self deselectFormRow:sender];
 
     if ([[CCUtility getBlockCode] length] == 0) {
@@ -375,6 +395,24 @@
         passcodeViewController.allowCancel = true;
         passcodeViewController.delegate = self;
         passcodeViewController.keypadButtonShowLettering = false;
+        
+        if ([laContext canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
+            if (error == NULL) {
+                if (@available(iOS 11.0.1, *)) {
+                    if (laContext.biometryType == LABiometryTypeFaceID) {
+                        passcodeViewController.biometryType = TOPasscodeBiometryTypeFaceID;
+                        passcodeViewController.allowBiometricValidation = true;
+                        passcodeViewController.automaticallyPromptForBiometricValidation = true;
+                    } else if (laContext.biometryType == LABiometryTypeTouchID) {
+                        passcodeViewController.biometryType = TOPasscodeBiometryTypeTouchID;
+                        passcodeViewController.allowBiometricValidation = true;
+                        passcodeViewController.automaticallyPromptForBiometricValidation = true;
+                    } else {
+                        NSLog(@"No Biometric support");
+                    }
+                }
+            }
+        }
 
         [self presentViewController:passcodeViewController animated:YES completion:nil];
     }

+ 1 - 1
iOSClient/Settings/NCManageEndToEndEncryption.m

@@ -31,7 +31,7 @@
 @interface NCManageEndToEndEncryption () <NCEndToEndInitializeDelegate, TOPasscodeViewControllerDelegate>
 {
     AppDelegate *appDelegate;
-    NSString *passcodeType = @"";
+    NSString *passcodeType;
 }
 @end