marinofaggiana 4 жил өмнө
parent
commit
efde2535d0

+ 0 - 3
iOSClient/Login/NCLogin.storyboard

@@ -31,9 +31,6 @@
                                 <color key="textColor" red="0.33333333333333331" green="0.33333333333333331" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="13"/>
                                 <textInputTraits key="textInputTraits" autocorrectionType="no" keyboardType="URL" returnKeyType="done"/>
-                                <connections>
-                                    <action selector="actionBaseUrlchange:" destination="yj9-jo-WIn" eventType="editingDidEnd" id="viw-GY-1Za"/>
-                                </connections>
                             </textField>
                             <textField opaque="NO" clipsSubviews="YES" tag="2" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="Username" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="1Gf-Bw-Nim">
                                 <rect key="frame" x="45" y="208" width="319" height="44"/>

+ 19 - 28
iOSClient/Login/NCLogin.swift

@@ -176,20 +176,17 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
         dismiss(animated: true) { }
     }
 
-    @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 }
-        
-        isUrlValid(url: url)
-    }
-    
     @IBAction func actionButtonLogin(_ sender: Any) {
         
         guard var url = baseUrl.text?.trimmingCharacters(in: .whitespacesAndNewlines) else { return }
         if url.hasSuffix("/") { url = String(url.dropLast()) }
         if url.count == 0 { return }
+        
+        // Check whether baseUrl contain protocol. If not add https:// by default.
+        if url.hasPrefix("https") == false && url.hasPrefix("http") == false {
+            url = "https://" + url
+        }
+        self.baseUrl.text = url
 
         if  currentLoginMode == .webFlow {
             
@@ -199,6 +196,9 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
             
             guard let username = user.text else { return }
             guard let password = password.text else { return }
+            
+            if username.count == 0 { return }
+            if password.count == 0 { return }
 
             loginButton.isEnabled = false
             activity.startAnimating()
@@ -254,15 +254,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
     // MARK: - Login
 
     func isUrlValid(url: String) {
-
-        var url = url
-        
-        // Check whether baseUrl contain protocol. If not add https:// by default.
-        if url.hasPrefix("https") == false && url.hasPrefix("http") == false {
-            url = "https://" + url
-            self.baseUrl.text = url
-        }
-        
+            
         loginButton.isEnabled = false
         activity.startAnimating()
         
@@ -274,7 +266,8 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                     
                     self.loginButton.isEnabled = true
                     self.activity.stopAnimating()
-                    
+                                        
+                    // 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 {
@@ -288,6 +281,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                             self.navigationController?.pushViewController(loginWeb, animated: true)
                         }
                         
+                    // Login Flow
                     } else if self.currentLoginMode == .webFlow && versionMajor >= NCGlobal.shared.nextcloudVersion12 {
                         
                         if let loginWeb = UIStoryboard(name: "NCLogin", bundle: nil).instantiateViewController(withIdentifier: "NCLoginWeb") as? NCLoginWeb {
@@ -297,15 +291,14 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                             self.navigationController?.pushViewController(loginWeb, animated: true)
                         }
                         
+                    // NO Login flow available
                     } else if versionMajor < NCGlobal.shared.nextcloudVersion12 {
                         
-                        self.loginModeButton.isHidden = true
+                        let alertController = UIAlertController(title: NSLocalizedString("_error_", comment: ""), message: NSLocalizedString("_webflow_not_available_", comment: ""), preferredStyle: .alert)
+
+                        alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in }))
                         
-                        self.imageUser.isHidden = false
-                        self.user.isHidden = false
-                        self.user.becomeFirstResponder()
-                        self.imagePassword.isHidden = false
-                        self.password.isHidden = false
+                        self.present(alertController, animated: true, completion: { })
                     }
                 }
                 
@@ -333,7 +326,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
                     
                 } else {
                     
-                    let alertController = UIAlertController(title: NSLocalizedString("_connection_error_", comment: ""), message: NSLocalizedString("_connect_server_anyway_", comment: ""), preferredStyle: .alert)
+                    let alertController = UIAlertController(title: NSLocalizedString("_connection_error_", comment: ""), message: errorDescription, preferredStyle: .alert)
 
                     alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in }))
                     
@@ -358,8 +351,6 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate {
             
             if let activeAccount = NCManageDatabase.shared.setAccountActive(account) {
                 appDelegate.settingAccount(activeAccount.account, urlBase: activeAccount.urlBase, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account))
-            } else {
-                
             }
             
             if CCUtility.getIntro() {

+ 1 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -349,6 +349,7 @@
 "_traditional_login_"           = "Revert to old login method";
 "_web_login_"                   = "Revert to web login method";
 "_login_url_error_"             = "URL error, please verify your server URL";
+"_webflow_not_available_"       = "Web login not available, use the old login method";
 
 // Favorite