瀏覽代碼

Improvement login

Marino Faggiana 7 年之前
父節點
當前提交
b92483e5d7
共有 1 個文件被更改,包括 7 次插入4 次删除
  1. 7 4
      iOSClient/Login/CCLogin.m

+ 7 - 4
iOSClient/Login/CCLogin.m

@@ -338,20 +338,23 @@
 
 - (void)getUserProfileSuccess:(CCMetadataNet *)metadataNet userProfile:(OCUserProfile *)userProfile
 {
-    // Set this account as default
-    tableAccount *tbAccount = [[NCManageDatabase sharedInstance] setAccountActive:metadataNet.account];
+    tableAccount *account = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account = %@", metadataNet.account]];
     
     // Verify account && ID
-    if ([tbAccount.account isEqualToString:metadataNet.account] && userProfile.id.length > 0) {
+    if (account && userProfile.id.length > 0) {
     
+        // Set this account as default
+        tableAccount *account = [[NCManageDatabase sharedInstance] setAccountActive:metadataNet.account];
+        
         // Setting App active account
-        [app settingActiveAccount:tbAccount.account activeUrl:tbAccount.url activeUser:tbAccount.user activePassword:tbAccount.password];
+        [app settingActiveAccount:account.account activeUrl:account.url activeUser:account.user activePassword:account.password];
     
         // Update User
         [[NCManageDatabase sharedInstance] setAccountsUserProfile:userProfile];
 
         // Dismiss
         [self.delegate loginSuccess:_loginType];
+        
         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
             [self dismissViewControllerAnimated:YES completion:nil];
         });