marinofaggiana 4 жил өмнө
parent
commit
9715161a2a

+ 1 - 1
iOSClient/Login/NCLogin.storyboard

@@ -97,7 +97,7 @@
                                     <color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 </state>
                                 <connections>
-                                    <action selector="handleButtonLogin:" destination="yj9-jo-WIn" eventType="touchUpInside" id="e6z-ip-PXo"/>
+                                    <action selector="actionButtonLogin:" destination="yj9-jo-WIn" eventType="touchUpInside" id="vFP-SJ-rFq"/>
                                 </connections>
                             </button>
                             <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="owR-PS-F32" userLabel="loginTypeView">

+ 10 - 13
iOSClient/Login/NCLogin.swift

@@ -177,7 +177,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
     }
 
     @IBAction func actionBaseUrlchange(_ sender: Any) {
-                
+        
         guard var url = baseUrl.text?.trimmingCharacters(in: .whitespacesAndNewlines) else { return }
         if url.hasSuffix("/") { url = String(url.dropLast()) }
         if url.count == 0 { return }
@@ -185,7 +185,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         isUrlValid(url: url)
     }
     
-    @IBAction func handleButtonLogin(_ sender: Any) {
+    @IBAction func actionButtonLogin(_ sender: Any) {
         
         guard var url = baseUrl.text?.trimmingCharacters(in: .whitespacesAndNewlines) else { return }
         if url.hasSuffix("/") { url = String(url.dropLast()) }
@@ -223,9 +223,9 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
     
     @IBAction func actionLoginModeButton(_ sender: Any) {
                 
-        if currentLoginMode == .traditional {
+        if currentLoginMode == .webFlow {
             
-            currentLoginMode = .webFlow
+            currentLoginMode = .traditional
             imageUser.isHidden = false
             user.isHidden = false
             imagePassword.isHidden = false
@@ -235,7 +235,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
             
         } else {
             
-            currentLoginMode = .traditional
+            currentLoginMode = .webFlow
             imageUser.isHidden = true
             user.isHidden = true
             imagePassword.isHidden = true
@@ -255,20 +255,17 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
 
     func isUrlValid(url: String) {
 
+        var url = url
+        
         // 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 ?? "")
+        if url.hasPrefix("https") == false && url.hasPrefix("http") == false {
+            url = "https://" + url
+            self.baseUrl.text = url
         }
         
-        guard var url = baseUrl.text else { return }
-        
         loginButton.isEnabled = false
         activity.startAnimating()
         
-        if url.hasSuffix("/") {
-            url = String(url.dropLast())
-        }
-        
         NCCommunication.shared.getServerStatus(serverUrl: url) { (serverProductName, serverVersion, versionMajor, versionMinor, versionMicro, extendedSupport, errorCode ,errorDescription) in
             
             if errorCode == 0 {