diff options
author | Stuart Connolly <stuart02@gmail.com> | 2017-03-21 19:59:55 +0000 |
---|---|---|
committer | Stuart Connolly <stuart02@gmail.com> | 2017-03-21 19:59:55 +0000 |
commit | 5906a91397ed42e74ab7671c8b1e98fb9bbf8c73 (patch) | |
tree | 37cdf56f2f26cd43ffd1b9b0ad2d2342c7adde9d /Source | |
parent | 48fd60cfc0db367f109434b7aa5bb20d63441b44 (diff) | |
download | sequelpro-5906a91397ed42e74ab7671c8b1e98fb9bbf8c73.tar.gz sequelpro-5906a91397ed42e74ab7671c8b1e98fb9bbf8c73.tar.bz2 sequelpro-5906a91397ed42e74ab7671c8b1e98fb9bbf8c73.zip |
Fix user manager throwing an exception when mysql.user.authentication_string is NULL.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPUserManager.h | 6 | ||||
-rw-r--r-- | Source/SPUserManager.m | 36 |
2 files changed, 28 insertions, 14 deletions
diff --git a/Source/SPUserManager.h b/Source/SPUserManager.h index 5ce1e6bc..ffee376d 100644 --- a/Source/SPUserManager.h +++ b/Source/SPUserManager.h @@ -81,7 +81,7 @@ BOOL isInitializing; NSMutableString *errorsString; - // MySQL 5.7.6 removes the "Password" columns and only uses the "plugin"+"authentication_string" columns + // MySQL 5.7.6 removes the "Password" columns and only uses the "plugin" + "authentication_string" columns BOOL requiresPost576PasswordHandling; } @@ -114,14 +114,14 @@ - (IBAction)closeErrorsSheet:(id)sender; - (IBAction)doubleClickSchemaPriv:(id)sender; -// Schema Privieges +// Schema privieges - (IBAction)addSchemaPriv:(id)sender; - (IBAction)removeSchemaPriv:(id)sender; // Refresh - (IBAction)refresh:(id)sender; -// Core Data notifications +// Core data notifications - (BOOL)insertUser:(SPUserMO *)user; - (BOOL)deleteUser:(SPUserMO *)user; - (BOOL)updateUser:(SPUserMO *)user; diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m index 8280242f..c06025d2 100644 --- a/Source/SPUserManager.m +++ b/Source/SPUserManager.m @@ -221,20 +221,24 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn"; */ - (void)_initializeTree:(NSArray *)items { - // Retrieve all the user data in order to be able to initialise the schema privs for each child, // copying into a dictionary keyed by user, each with all the host rows. NSMutableDictionary *schemaPrivilegeData = [NSMutableDictionary dictionary]; SPMySQLResult *queryResults = [connection queryString:@"SELECT * FROM mysql.db"]; + [queryResults setReturnDataAsStrings:YES]; - for (NSDictionary *privRow in queryResults) { + + for (NSDictionary *privRow in queryResults) + { if (![schemaPrivilegeData objectForKey:[privRow objectForKey:@"User"]]) { [schemaPrivilegeData setObject:[NSMutableArray array] forKey:[privRow objectForKey:@"User"]]; } + [[schemaPrivilegeData objectForKey:[privRow objectForKey:@"User"]] addObject:privRow]; // If "all database" values were found, add them to the schemas list if not already present NSString *schemaName = [privRow objectForKey:@"Db"]; + if ([schemaName isEqualToString:@""] || [schemaName isEqualToString:@"%"]) { if (![schemas containsObject:schemaName]) { [schemas addObject:schemaName]; @@ -269,11 +273,20 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn"; // original values for comparison purposes [parent setPrimitiveValue:username forKey:@"user"]; [parent setPrimitiveValue:username forKey:@"originaluser"]; - if(requiresPost576PasswordHandling) { + + if (requiresPost576PasswordHandling) { [parent setPrimitiveValue:[item objectForKey:@"plugin"] forKey:@"plugin"]; - NSString *pwHash = [item objectForKey:@"authentication_string"]; - [parent setPrimitiveValue:pwHash forKey:@"authentication_string"]; - if([pwHash length]) [parent setPrimitiveValue:@"sequelpro_dummy_password" forKey:@"password"]; // for the UI dialog + + NSString *passwordHash = [item objectForKey:@"authentication_string"]; + + if (![passwordHash isNSNull]) { + [parent setPrimitiveValue:passwordHash forKey:@"authentication_string"]; + + // for the UI dialog + if ([passwordHash length]) { + [parent setPrimitiveValue:@"sequelpro_dummy_password" forKey:@"password"]; + } + } } else { [parent setPrimitiveValue:[item objectForKey:@"Password"] forKey:@"password"]; @@ -535,7 +548,6 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn"; */ - (IBAction)doApply:(id)sender { - // If editing can't be committed, cancel the apply if (![treeController commitEditing]) { return; @@ -953,6 +965,9 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn"; if (!isInitializing) [outlineView reloadData]; } +#pragma mark - +#pragma mark Core data notifications + - (BOOL)updateUser:(SPUserMO *)user { if (![user parent]) { @@ -1290,6 +1305,9 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn"; return YES; } +#pragma mark - +#pragma mark Private API + /** * Gets any NSManagedObject (SPUser) from the managedObjectContext that may * already exist with the given username. @@ -1446,9 +1464,6 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn"; return YES; } -#pragma mark - -#pragma mark Private API - /** * Renames a user account using the supplied parameters. * @@ -1511,7 +1526,6 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn"; { [[NSNotificationCenter defaultCenter] removeObserver:self]; - SPClear(managedObjectContext); SPClear(persistentStoreCoordinator); SPClear(managedObjectModel); |