浏览代码

fix checkTrustedChallenge [rollback] + host

Signed-off-by: marinofaggiana <marino@marinofaggiana.com>
marinofaggiana 3 年之前
父节点
当前提交
d5fe05a3e3
共有 2 个文件被更改,包括 67 次插入15 次删除
  1. 2 2
      iOSClient/Login/NCLogin.storyboard
  2. 65 13
      iOSClient/Login/NCLogin.swift

+ 2 - 2
iOSClient/Login/NCLogin.storyboard

@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="18093"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>

+ 65 - 13
iOSClient/Login/NCLogin.swift

@@ -270,25 +270,33 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                     // Login Flow V2
                     if errorCode == 0 && NCBrandOptions.shared.use_loginflowv2 && token != nil && endpoint != nil && login != nil {
                         
-                        if let loginWeb = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLoginWeb") as? NCLoginWeb {
-                            
-                            loginWeb.urlBase = url
-                            loginWeb.loginFlowV2Available = true
-                            loginWeb.loginFlowV2Token = token!
-                            loginWeb.loginFlowV2Endpoint = endpoint!
-                            loginWeb.loginFlowV2Login = login!
-                            
-                            self.navigationController?.pushViewController(loginWeb, animated: true)
+                        self.checkPushNotificationServerProxy { error in
+                            if !error {
+                                if let loginWeb = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLoginWeb") as? NCLoginWeb {
+                                    
+                                    loginWeb.urlBase = url
+                                    loginWeb.loginFlowV2Available = true
+                                    loginWeb.loginFlowV2Token = token!
+                                    loginWeb.loginFlowV2Endpoint = endpoint!
+                                    loginWeb.loginFlowV2Login = login!
+                                    
+                                    self.navigationController?.pushViewController(loginWeb, animated: true)
+                                }
+                            }
                         }
                         
                     // Login Flow
                     } else if versionMajor >= NCGlobal.shared.nextcloudVersion12 {
                         
-                        if let loginWeb = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLoginWeb") as? NCLoginWeb {
-                            
-                            loginWeb.urlBase = url
+                        self.checkPushNotificationServerProxy { error in
+                            if !error {
+                                if let loginWeb = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLoginWeb") as? NCLoginWeb {
+                                    
+                                    loginWeb.urlBase = url
 
-                            self.navigationController?.pushViewController(loginWeb, animated: true)
+                                    self.navigationController?.pushViewController(loginWeb, animated: true)
+                                }
+                            }
                         }
                         
                     // NO Login flow available
@@ -461,4 +469,48 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
             }
         }
     }
+    
+    // MARK: -
+    
+    func checkPushNotificationServerProxy(completion: @escaping (_ error: Bool)->()) {
+        
+        let url = NCBrandOptions.shared.pushNotificationServerProxy
+        
+        NCCommunication.shared.checkServer(serverUrl: url) { (errorCode, errorDescription) in
+            
+            if errorCode == 0 {
+                
+                completion(false)
+                
+            } else if errorCode == NSURLErrorServerCertificateUntrusted {
+                
+                let alertController = UIAlertController(title: NSLocalizedString("_ssl_certificate_untrusted_", comment: ""), message: NSLocalizedString("_connect_server_anyway_", comment: ""), preferredStyle: .alert)
+                            
+                alertController.addAction(UIAlertAction(title: NSLocalizedString("_yes_", comment: ""), style: .default, handler: { action in
+                    if let host = URL(string: url)?.host {
+                        NCNetworking.shared.writeCertificate(host: host)
+                    }
+                    self.appDelegate.startTimerErrorNetworking()
+                    completion(false)
+                }))
+                
+                alertController.addAction(UIAlertAction(title: NSLocalizedString("_no_", comment: ""), style: .default, handler: { action in
+                    self.appDelegate.startTimerErrorNetworking()
+                    completion(true)
+                }))
+                
+                alertController.addAction(UIAlertAction(title: NSLocalizedString("_certificate_details_", comment: ""), style: .default, handler: { action in
+                    if let navigationController = UIStoryboard(name: "NCViewCertificateDetails", bundle: nil).instantiateInitialViewController() {
+                        self.present(navigationController, animated: true)
+                    }
+                }))
+                
+                self.present(alertController, animated: true, completion: {
+                    self.appDelegate.timerErrorNetworking?.invalidate()
+                })
+            }
+        }
+    }
+    
+
 }