marinofaggiana 5 years ago
parent
commit
d101534faa

+ 1 - 1
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 delegate:self loginType:k_login_Modify_Password selector:k_intro_login];
+        [self openLoginView:self.window.rootViewController delegate:self loginType:k_login_Add selector:k_intro_login];
     }
     
     // check certificate untrusted (-1202)

+ 0 - 1
iOSClient/CCGlobal.h

@@ -92,7 +92,6 @@
 #define k_login_Add                                     0
 #define k_login_Add_Forced                              1
 #define k_login_Add_SignUp                              2
-#define k_login_Modify_Password                         3
 
 // Picker select image
 #define k_pickerControllerMax                           1000.0

+ 20 - 48
iOSClient/Login/CCLogin.m

@@ -118,15 +118,6 @@
         _password.hidden = YES;
         _annulla.hidden = YES;
     }
-    
-    if (_loginType == k_login_Modify_Password) {
-        _baseUrl.text = appDelegate.activeUrl;
-        _baseUrl.userInteractionEnabled = NO;
-        _baseUrl.textColor = [UIColor lightGrayColor];
-        _user.text = appDelegate.activeUser;
-        _user.userInteractionEnabled = NO;
-        _user.textColor = [UIColor lightGrayColor];
-    }
 }
 
 - (void)viewWillAppear:(BOOL)animated
@@ -134,7 +125,7 @@
     [super viewWillAppear:animated];
 
     // verify URL
-    if (_loginType == k_login_Modify_Password && [self.baseUrl.text length] > 0)
+    if ([self.baseUrl.text length] > 0)
         [self testUrl];
 }
 
@@ -239,8 +230,8 @@
 
 - (void)trustedCerticateDenied
 {
-    if (_loginType == k_login_Modify_Password)
-        [self handleAnnulla:self];
+   // if (_loginType == k_login_Modify_Password)
+        //[self handleAnnulla:self];
 }
 
 #pragma --------------------------------------------------------------------------------------------
@@ -348,42 +339,23 @@
                 
                 NSString *account = [NSString stringWithFormat:@"%@ %@", user, url];
                 
-                if (_loginType == k_login_Modify_Password) {
-                    
-                    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountActive:account];
-                    
-                    // Change Password
-                    [CCUtility setPassword:account password:token];
-                    
-                    // Setting appDelegate active account
-                    [appDelegate settingActiveAccount:account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:token];
-                    
-                    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
-                    
-                    [self dismissViewControllerAnimated:YES completion:nil];
-                    
-                } else {
-                    
-                    // NO account found, clear
-                    if ([NCManageDatabase.sharedInstance getAccounts] == nil) { [NCUtility.sharedInstance removeAllSettings]; }
-                    
-                    // STOP Intro
-                    [CCUtility setIntro:YES];
-                    
-                    [[NCManageDatabase sharedInstance] deleteAccount:account];
-                    [[NCManageDatabase sharedInstance] addAccount:account url:url user:user password:token];
-                    
-                    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountActive:account];
-                    
-                    // Setting appDelegate active account
-                    [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:[CCUtility getPassword:tableAccount.account]];
-                    
-                    [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
-                    
-                    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
-                        [self dismissViewControllerAnimated:YES completion:nil];
-                    });
-                }
+                // NO account found, clear
+                if ([NCManageDatabase.sharedInstance getAccounts] == nil) { [NCUtility.sharedInstance removeAllSettings]; }
+                
+                // STOP Intro
+                [CCUtility setIntro:YES];
+                
+                [[NCManageDatabase sharedInstance] deleteAccount:account];
+                [[NCManageDatabase sharedInstance] addAccount:account url:url user:user password:token];
+                
+                tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountActive:account];
+                
+                // Setting appDelegate active account
+                [appDelegate settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activeUserID:tableAccount.userID activePassword:[CCUtility getPassword:tableAccount.account]];
+                
+                [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:@"initializeMain" object:nil userInfo:nil];
+                
+                [self dismissViewControllerAnimated:YES completion:nil];
                 
             } else {
                 

+ 14 - 43
iOSClient/Login/NCLoginWeb.swift

@@ -132,56 +132,27 @@ extension NCLoginWeb: WKNavigationDelegate {
                     
                     let account : String = "\(username) \(serverUrl)"
                     
-                    // Login Flow
-                    if (loginType == k_login_Modify_Password && NCBrandOptions.sharedInstance.use_login_web_personalized == false) {
+                    // NO account found, clear
+                    if NCManageDatabase.sharedInstance.getAccounts() == nil { NCUtility.sharedInstance.removeAllSettings() }
                         
-                        // Verify if change the active account
-                        guard let activeAccount = NCManageDatabase.sharedInstance.getAccountActive() else {
-                            self.dismiss(animated: true, completion: nil)
-                            return
-                        }
-                        if (activeAccount.account != account) {
-                            self.dismiss(animated: true, completion: nil)
-                            return
-                        }
+                    // STOP Intro
+                    CCUtility.setIntro(true)
                         
-                        // Change Password & setting active account
-                        CCUtility.setPassword(account, password: token)
-                        appDelegate.settingActiveAccount(account, activeUrl: serverUrl, activeUser: username, activeUserID: appDelegate.activeUserID, activePassword: token)
+                    // Add new account
+                    NCManageDatabase.sharedInstance.deleteAccount(account)
+                    NCManageDatabase.sharedInstance.addAccount(account, url: serverUrl, user: username, password: token)
                         
-                        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil, userInfo: nil)
-                        
-                        self.dismiss(animated: true) {
-                            self.delegate?.loginWebDismiss?()
-                        }
+                    guard let tableAccount = NCManageDatabase.sharedInstance.setAccountActive(account) else {
+                        self.dismiss(animated: true, completion: nil)
+                        return
                     }
-                    
-                    if (loginType == k_login_Add || loginType == k_login_Add_Forced) {
-                        
-                        // NO account found, clear
-                        if NCManageDatabase.sharedInstance.getAccounts() == nil {
-                            NCUtility.sharedInstance.removeAllSettings()
-                        }
-                        
-                        // STOP Intro
-                        CCUtility.setIntro(true)
-                        
-                        // Add new account
-                        NCManageDatabase.sharedInstance.deleteAccount(account)
-                        NCManageDatabase.sharedInstance.addAccount(account, url: serverUrl, user: username, password: token)
-                        
-                        guard let tableAccount = NCManageDatabase.sharedInstance.setAccountActive(account) else {
-                            self.dismiss(animated: true, completion: nil)
-                            return
-                        }
                         
-                        appDelegate.settingActiveAccount(account, activeUrl: serverUrl, activeUser: username, activeUserID: tableAccount.userID, activePassword: token)
+                    appDelegate.settingActiveAccount(account, activeUrl: serverUrl, activeUser: username, activeUserID: tableAccount.userID, activePassword: token)
                         
-                        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil, userInfo: nil)
+                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "initializeMain"), object: nil, userInfo: nil)
                         
-                        self.dismiss(animated: true) {
-                            self.delegate?.loginWebDismiss?()
-                        }
+                    self.dismiss(animated: true) {
+                        self.delegate?.loginWebDismiss?()
                     }
                 }
             }

+ 1 - 1
iOSClient/Settings/CCManageAccount.m

@@ -407,7 +407,7 @@
 {    
     [self deselectFormRow:sender];
     
-    [appDelegate openLoginView:self delegate:self loginType:k_login_Modify_Password selector:k_intro_login];
+    [appDelegate openLoginView:self delegate:self loginType:k_login_Add selector:k_intro_login];
 }
 
 #pragma --------------------------------------------------------------------------------------------