marinofaggiana 5 роки тому
батько
коміт
0e4c4b2887

+ 2 - 4
iOSClient/AppDelegate.h

@@ -139,11 +139,9 @@
 // UserDefaults
 @property (nonatomic, strong) NSUserDefaults *ncUserDefaults;
 
-// Timer Error Networking
+// Login
 - (void)startTimerErrorNetworking;
-
-// Login View
-- (void)openLoginView:(UIViewController *)viewController selector:(NSInteger)selector;
+- (void)openLoginView:(UIViewController *)viewController selector:(NSInteger)selector unauthorized:(BOOL)unauthorized;
 
 // Setting Account
 - (void)settingActiveAccount:(NSString *)activeAccount activeUrl:(NSString *)activeUrl activeUser:(NSString *)activeUser activeUserID:(NSString *)activeUserID activePassword:(NSString *)activePassword;

+ 14 - 5
iOSClient/AppDelegate.m

@@ -269,7 +269,7 @@ PKPushRegistry *pushRegistry;
     
     // check unauthorized server (401)
     if ([CCUtility getPassword:self.activeAccount].length == 0) {
-        [self openLoginView:self.window.rootViewController selector:k_intro_login];
+        [self openLoginView:self.window.rootViewController selector:k_intro_login unauthorized:true];
     }
     
     // check certificate untrusted (-1202)
@@ -278,7 +278,7 @@ PKPushRegistry *pushRegistry;
     }
 }
 
-- (void)openLoginView:(UIViewController *)viewController selector:(NSInteger)selector
+- (void)openLoginView:(UIViewController *)viewController selector:(NSInteger)selector unauthorized:(BOOL)unauthorized
 {
     @synchronized (self) {
 
@@ -303,7 +303,6 @@ PKPushRegistry *pushRegistry;
             if (!(_activeLoginWeb.isViewLoaded && _activeLoginWeb.view.window)) {
                 
                 self.activeLoginWeb = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"NCLoginWeb"];
-                
                 self.activeLoginWeb.urlBase = [[NCBrandOptions sharedInstance] loginBaseUrl];
 
                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
@@ -335,13 +334,23 @@ PKPushRegistry *pushRegistry;
         } else if ([NCBrandOptions sharedInstance].disable_intro && [NCBrandOptions sharedInstance].disable_request_login_url) {
             
             self.activeLoginWeb = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"NCLoginWeb"];
-            
             self.activeLoginWeb.urlBase = [[NCBrandOptions sharedInstance] loginBaseUrl];
             
             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                 [viewController presentViewController:self.activeLoginWeb animated:YES completion:nil];
             });
             
+        } else if (unauthorized) {
+            
+            if (!(_activeLoginWeb.isViewLoaded && _activeLoginWeb.view.window)) {
+                self.activeLoginWeb = [[UIStoryboard storyboardWithName:@"CCLogin" bundle:nil] instantiateViewControllerWithIdentifier:@"NCLoginWeb"];
+                self.activeLoginWeb.urlBase = self.activeUrl;
+
+                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+                    [viewController presentViewController:self.activeLoginWeb animated:YES completion:nil];
+                });
+            }
+            
         } else {
             
             if (!(_activeLogin.isViewLoaded && _activeLogin.view.window)) {
@@ -403,7 +412,7 @@ PKPushRegistry *pushRegistry;
             [self settingActiveAccount:newAccount activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:[CCUtility getPassword:tableAccount.account]];
             [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
         } else {
-            [self openLoginView:self.window.rootViewController selector:k_intro_login];
+            [self openLoginView:self.window.rootViewController selector:k_intro_login unauthorized:false];
         }
     }
 }

+ 1 - 1
iOSClient/Main/CCMain.m

@@ -2075,7 +2075,7 @@
 
 - (void)addNewAccount:(CCMenuItem *)sender
 {
-    [appDelegate openLoginView:self selector:k_intro_login];
+    [appDelegate openLoginView:self selector:k_intro_login unauthorized:false];
 }
 
 #pragma --------------------------------------------------------------------------------------------

+ 1 - 1
iOSClient/Main/CCMore.swift

@@ -436,7 +436,7 @@ class CCMore: UIViewController, UITableViewDelegate, UITableViewDataSource {
                 let manageAccount = CCManageAccount()
                 manageAccount.delete(self.appDelegate.activeAccount)
                 
-                self.appDelegate.openLoginView(self, selector: Int(k_intro_login)) 
+                self.appDelegate.openLoginView(self, selector: Int(k_intro_login), unauthorized:false)
             }
             
             let actionNo = UIAlertAction(title: NSLocalizedString("_no_delete_", comment: ""), style: .default) { (action:UIAlertAction) in

+ 4 - 4
iOSClient/Main/CCSplit.m

@@ -134,7 +134,7 @@
     if ([NCBrandOptions sharedInstance].disable_intro) {
         
         [CCUtility setIntro:YES];
-        [appDelegate openLoginView:self selector:k_intro_login];
+        [appDelegate openLoginView:self selector:k_intro_login unauthorized:false];
         
     
     } else {
@@ -146,7 +146,7 @@
         
         } else {
             if (appDelegate.activeAccount.length == 0) {
-                [appDelegate openLoginView:self selector:k_intro_login];
+                [appDelegate openLoginView:self selector:k_intro_login unauthorized:false];
             }
         }
     }
@@ -160,7 +160,7 @@
             {
                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                     if (appDelegate.activeAccount.length == 0) {
-                        [appDelegate openLoginView:self selector:k_intro_login];
+                        [appDelegate openLoginView:self selector:k_intro_login unauthorized:false];
                     }
                 });
             }
@@ -168,7 +168,7 @@
             
         case k_intro_signup:
             {
-                [appDelegate openLoginView:self selector:k_intro_signup];
+                [appDelegate openLoginView:self selector:k_intro_signup unauthorized:false];
             }
             break;
     }

+ 3 - 3
iOSClient/Settings/CCManageAccount.m

@@ -338,7 +338,7 @@
     
     // Open Login
     if (listAccount.count == 0) {
-        [appDelegate openLoginView:self selector:k_intro_login];
+        [appDelegate openLoginView:self selector:k_intro_login unauthorized:false];
     }
 }
 
@@ -396,7 +396,7 @@
 {
     [self deselectFormRow:sender];
     
-    [appDelegate openLoginView:self selector:k_intro_login];
+    [appDelegate openLoginView:self selector:k_intro_login unauthorized:false];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -407,7 +407,7 @@
 {    
     [self deselectFormRow:sender];
     
-    [appDelegate openLoginView:self selector:k_intro_login];
+    [appDelegate openLoginView:self selector:k_intro_login unauthorized:false];
 }
 
 #pragma --------------------------------------------------------------------------------------------