Marino Faggiana 7 éve
szülő
commit
1af75a7f2d

+ 1 - 1
iOSClient/Brand/Picker.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.17.6</string>
 	<key>CFBundleVersion</key>
-	<string>00004</string>
+	<string>00005</string>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>

+ 1 - 1
iOSClient/Brand/PickerFileProvider.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.17.6</string>
 	<key>CFBundleVersion</key>
-	<string>00004</string>
+	<string>00005</string>
 	<key>NSExtension</key>
 	<dict>
 		<key>NSExtensionFileProviderDocumentGroup</key>

+ 1 - 1
iOSClient/Brand/Share.plist

@@ -19,7 +19,7 @@
 	<key>CFBundleShortVersionString</key>
 	<string>2.17.6</string>
 	<key>CFBundleVersion</key>
-	<string>00004</string>
+	<string>00005</string>
 	<key>NSAppTransportSecurity</key>
 	<dict>
 		<key>NSAllowsArbitraryLoads</key>

+ 1 - 1
iOSClient/Brand/iOSClient.plist

@@ -69,7 +69,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>00004</string>
+	<string>00005</string>
 	<key>Fabric</key>
 	<dict>
 		<key>APIKey</key>

+ 1 - 0
iOSClient/Database/NCDatabase.swift

@@ -52,6 +52,7 @@ class tableAccount: Object {
     dynamic var twitter = ""
     dynamic var url = ""
     dynamic var user = ""
+    dynamic var username = ""
     dynamic var webpage = ""
 }
 

+ 13 - 2
iOSClient/Database/NCManageDatabase.swift

@@ -57,11 +57,11 @@ class NCManageDatabase: NSObject {
         let config = Realm.Configuration(
         
             fileURL: dirGroup?.appendingPathComponent("\(appDatabaseNextcloud)/\(k_databaseDefault)"),
-            schemaVersion: 5,
+            schemaVersion: 6,
             
             migrationBlock: { migration, oldSchemaVersion in
                 // We haven’t migrated anything yet, so oldSchemaVersion == 0
-                if (oldSchemaVersion < 5) {
+                if (oldSchemaVersion < 6) {
                     // Nothing to do!
                     // Realm will automatically detect new properties and removed properties
                     // And will update the schema on disk automatically
@@ -410,6 +410,17 @@ class NCManageDatabase: NSObject {
                     return
                 }
                 
+                // Copy user -> username 
+                // https://github.com/nextcloud/ios/issues/331
+                if result.username.characters.count == 0 {
+                    result.username = result.user
+                }
+                
+                // Update user with ID
+                if userProfile.id.characters.count > 0 {
+                    result.user = userProfile.id
+                }
+                
                 result.enabled = userProfile.enabled
                 result.address = userProfile.address
                 result.displayName = userProfile.displayName

+ 36 - 26
iOSClient/Login/CCLogin.m

@@ -285,38 +285,21 @@
             
             [[NCManageDatabase sharedInstance] setAccountPassword:account password:self.password.text];
             
+            // Dismiss
+            [self.delegate loginSuccess:_loginType];
+            [self dismissViewControllerAnimated:YES completion:nil];
+            
         } else {
 
             [[NCManageDatabase sharedInstance] deleteAccount:account];
-        
-            // Add account
             [[NCManageDatabase sharedInstance] addAccount:account url:self.baseUrl.text user:self.user.text password:self.password.text];
-        }
-        
-        // Set this account as default
-        tableAccount *tableAccount = [[NCManageDatabase sharedInstance] setAccountActive:account];
-        
-        // verifica
-        if ([tableAccount.account isEqualToString:account]) {
-            
-            [app settingActiveAccount:tableAccount.account activeUrl:tableAccount.url activeUser:tableAccount.user activePassword:tableAccount.password];
             
-            [self.delegate loginSuccess:_loginType];
-            
-            // close
-            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
-                [self dismissViewControllerAnimated:YES completion:nil];
-            });
-            
-        } else {
-            
-            if (_loginType != loginModifyPasswordUser)
-                [[NCManageDatabase sharedInstance] deleteAccount:account];
-            
-            alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"_error_", nil) message:@"Fatal error writing database" delegate:nil cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"_ok_", nil), nil];
-            [alertView show];
+            // Read User Profile
+            CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:account];
+            metadataNet.action = actionGetUserProfile;
+            [app.netQueue addOperation:[[OCnetworking alloc] initWithDelegate:self metadataNet:metadataNet withUser:self.user.text withPassword:self.password.text withUrl:[self.baseUrl.text stringByAppendingString:webDAV] isCryptoCloudMode:NO]];
         }
-
+        
     } else {
         
         if ([error code] != NSURLErrorServerCertificateUntrusted) {
@@ -333,6 +316,33 @@
     self.loadingBaseUrl.hidden = YES;
 }
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark ==== User Profile  ====
+#pragma --------------------------------------------------------------------------------------------
+
+- (void)getUserProfileFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
+{
+    [[NCManageDatabase sharedInstance] deleteAccount:metadataNet.account];
+    
+    alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"_error_", nil) message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"_ok_", nil), nil];
+    [alertView show];
+}
+
+- (void)getUserProfileSuccess:(CCMetadataNet *)metadataNet userProfile:(OCUserProfile *)userProfile
+{
+    // Update User
+    [[NCManageDatabase sharedInstance] setAccountsUserProfile:userProfile];
+    
+    // Set this account as default
+    (void)[[NCManageDatabase sharedInstance] setAccountActive:metadataNet.account];
+    
+    // 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];
+    });
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark == TextField ==
 #pragma --------------------------------------------------------------------------------------------