浏览代码

service

Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
Marino Faggiana 1 年之前
父节点
当前提交
0c237854eb

+ 0 - 3
iOSClient/AppDelegate.swift

@@ -41,7 +41,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
     @objc var userId: String = ""
     @objc var password: String = ""
 
-    var deletePasswordSession: Bool = false
     var activeLogin: NCLogin?
     var activeLoginWeb: NCLoginWeb?
     var activeServerUrl: String = ""
@@ -193,8 +192,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
         NCNetworkingProcessUpload.shared.observeTableMetadata()
         NCNetworkingProcessUpload.shared.startTimer()
 
-        self.deletePasswordSession = false
-
         if !NCAskAuthorization.shared.isRequesting {
             hidePrivacyProtectionWindow()
         }

+ 2 - 1
iOSClient/NCGlobal.swift

@@ -208,12 +208,13 @@ class NCGlobal: NSObject {
     @objc let errorRequestExplicityCancelled: Int   = 15
     @objc let errorNotModified: Int                 = 304
     @objc let errorBadRequest: Int                  = 400
-    @objc let errorUnauthorized: Int                = 401
+    @objc let errorUnauthorized401: Int             = 401
     @objc let errorForbidden: Int                   = 403
     @objc let errorResourceNotFound: Int            = 404
     @objc let errordMethodNotSupported: Int         = 405
     @objc let errorConflict: Int                    = 409
     @objc let errorPreconditionFailed: Int          = 412
+    @objc let errorUnauthorized997: Int             = 997
     @objc let errorConnectionLost: Int              = -1005
     @objc let errorNetworkNotAvailable: Int         = -1009
     @objc let errorBadServerResponse: Int           = -1011

+ 4 - 2
iOSClient/Networking/NCNetworkingCheckRemoteUser.swift

@@ -58,14 +58,16 @@ class NCNetworkingCheckRemoteUser {
 
                 } else {
 
-                    if UIApplication.shared.applicationState == .active && NextcloudKit.shared.isNetworkReachable() && !CCUtility.getPassword(account).isEmpty && !appDelegate.deletePasswordSession {
+                    NCContentPresenter.shared.showError(error: error, priority: .max)
+                    /*
+                    if UIApplication.shared.applicationState == .active && NextcloudKit.shared.isNetworkReachable() && !CCUtility.getPassword(account).isEmpty {
                         let description = String.localizedStringWithFormat(NSLocalizedString("_error_check_remote_user_", comment: ""), tableAccount.user, tableAccount.urlBase)
                         let error = NKError(errorCode: error.errorCode, errorDescription: description)
                         NCContentPresenter.shared.showError(error: error, priority: .max)
                         CCUtility.setPassword(account, password: nil)
                         NextcloudKit.shared.nkCommonInstance.writeLog("[INFO] Password removed.")
-                        appDelegate.deletePasswordSession = true
                     }
+                    */
                 }
             }
 

+ 7 - 5
iOSClient/Networking/NCService.swift

@@ -114,24 +114,26 @@ class NCService: NSObject {
 
         if resultUserProfile.error == .success, let userProfile = resultUserProfile.userProfile {
             guard let tableAccount = NCManageDatabase.shared.setAccountUserProfile(account: resultUserProfile.account, userProfile: userProfile) else {
-                let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "Internal error : account not found on DB")
+                let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "Internal error: account not found on DB")
                 NCContentPresenter.shared.showError(error: error, priority: .max)
                 return (false, nil)
             }
             await self.appDelegate.settingAccount(tableAccount.account, urlBase: tableAccount.urlBase, user: tableAccount.user, userId: tableAccount.userId, password: CCUtility.getPassword(tableAccount.account))
             return (true, tableAccount)
-        } else if resultUserProfile.error.errorCode == NCGlobal.shared.errorUnauthorized {
+        } else if resultUserProfile.error.errorCode == NCGlobal.shared.errorUnauthorized401 ||
+                    resultUserProfile.error.errorCode == NCGlobal.shared.errorUnauthorized997 {
             // Ops the server has Unauthorized
             DispatchQueue.main.async {
                 if UIApplication.shared.applicationState == .active && NCNetworking.shared.networkReachability != NKCommon.TypeReachability.notReachable {
-                    NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] The server has response with Unauthorized \(resultUserProfile.error.errorCode)")
+                    NextcloudKit.shared.nkCommonInstance.writeLog("[ERROR] The server has response with Unauthorized go checkRemoteUser \(resultUserProfile.error.errorCode)")
                     NCNetworkingCheckRemoteUser().checkRemoteUser(account: resultUserProfile.account, error: resultUserProfile.error)
                 }
             }
             return (false, nil)
+        } else {
+            NCContentPresenter.shared.showError(error: resultUserProfile.error, priority: .max)
+            return (false, nil)
         }
-
-        return (false, nil)
     }
 
     func synchronize(tableAccount: tableAccount) {