소스 검색

new NCLogin

marinofaggiana 4 년 전
부모
커밋
3433342e5f
2개의 변경된 파일12개의 추가작업 그리고 17개의 파일을 삭제
  1. 2 2
      iOSClient/Login/NCLogin.storyboard
  2. 10 15
      iOSClient/Login/NCLogin.swift

+ 2 - 2
iOSClient/Login/NCLogin.storyboard

@@ -79,7 +79,7 @@
                                 </constraints>
                                 <state key="normal" image="visiblePassword" backgroundImage="visiblePassword"/>
                                 <connections>
-                                    <action selector="handleToggleVisiblePassword:" destination="yj9-jo-WIn" eventType="touchUpInside" id="if0-s4-Gzt"/>
+                                    <action selector="actionToggleVisiblePassword:" destination="yj9-jo-WIn" eventType="touchUpInside" id="n5I-x0-ngr"/>
                                 </connections>
                             </button>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="HQd-pF-3cE">
@@ -118,7 +118,7 @@
                                     <constraint firstAttribute="height" constant="50" id="OLT-tb-4Qb"/>
                                 </constraints>
                                 <connections>
-                                    <action selector="handleQRCode:" destination="yj9-jo-WIn" eventType="touchUpInside" id="IW6-a9-880"/>
+                                    <action selector="actionQRCode:" destination="yj9-jo-WIn" eventType="touchUpInside" id="qwL-rG-ead"/>
                                 </connections>
                             </button>
                         </subviews>

+ 10 - 15
iOSClient/Login/NCLogin.swift

@@ -213,7 +213,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         }
     }
     
-    @IBAction func handleToggleVisiblePassword(_ sender: Any) {
+    @IBAction func actionToggleVisiblePassword(_ sender: Any) {
         
         let currentPassword = self.password.text
         
@@ -245,7 +245,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         }
     }
     
-    @IBAction func handleQRCode(_ sender: Any) {
+    @IBAction func actionQRCode(_ sender: Any) {
         
         let qrCode = NCLoginQRCode.init(delegate: self)
         qrCode.scan()
@@ -396,32 +396,27 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         
         let protocolLogin = NCBrandOptions.shared.webLoginAutenticationProtocol + "login/"
         
-        if value.hasPrefix("protocolLogin") && value.contains("user:") && value.contains("password:") && value.contains("server:") {
+        if value.hasPrefix(protocolLogin) && value.contains("user:") && value.contains("password:") && value.contains("server:") {
             
             value = value.replacingOccurrences(of: protocolLogin, with: "")
             let valueArray = value.components(separatedBy: "&")
             if valueArray.count == 3 {
-                user.text = valueArray[0].replacingOccurrences(of: "user:", with: "")
-                password.text = valueArray[1].replacingOccurrences(of: "password:", with: "")
-                baseUrl.text = valueArray[2].replacingOccurrences(of: "server:", with: "")
                 
-                // Check whether baseUrl contain protocol. If not add https:// by default.
-                if (baseUrl.text?.hasPrefix("https") ?? false) == false && (baseUrl.text?.hasPrefix("http") ?? false) == false {
-                    self.baseUrl.text = "https://" + (self.baseUrl.text ?? "")
-                }
+                let user = valueArray[0].replacingOccurrences(of: "user:", with: "")
+                let password = valueArray[1].replacingOccurrences(of: "password:", with: "")
+                let urlBase = valueArray[2].replacingOccurrences(of: "server:", with: "")
+                let webDAV = NCUtilityFileSystem.shared.getWebDAV(account: appDelegate.account)
+                let serverUrl = urlBase + "/" + webDAV
                 
                 loginButton.isEnabled = false
                 activity.startAnimating()
                 
-                let webDAV = NCUtilityFileSystem.shared.getWebDAV(account: appDelegate.account)
-                let serverUrl = (baseUrl.text ?? "") + "/" + webDAV
-                
                 NCCommunication.shared.checkServer(serverUrl: serverUrl) { (errorCode, errorDescription) in
-                    
+                
                     self.activity.stopAnimating()
                     self.loginButton.isEnabled = true
                     
-                    self.standardLogin(urlBase: self.baseUrl.text!, user: self.user.text!, token: self.password.text!, errorCode: errorCode, errorDescription: errorDescription)
+                    self.standardLogin(urlBase: urlBase, user: user, token: password, errorCode: errorCode, errorDescription: errorDescription)
                 }
             }
         }