diff options
author | Max Lohrmann <dmoagx@users.noreply.github.com> | 2016-12-07 14:18:47 +0100 |
---|---|---|
committer | Max Lohrmann <dmoagx@users.noreply.github.com> | 2016-12-07 14:18:47 +0100 |
commit | 7a3152affb59b1cb402ca0d1b46b5a228ffedb79 (patch) | |
tree | 947e560f7c8241bb60ab6497c071163304f8cc66 /Source | |
parent | 56badea5971212fbeb168111cd4ead2d9a9e69b0 (diff) | |
download | sequelpro-7a3152affb59b1cb402ca0d1b46b5a228ffedb79.tar.gz sequelpro-7a3152affb59b1cb402ca0d1b46b5a228ffedb79.tar.bz2 sequelpro-7a3152affb59b1cb402ca0d1b46b5a228ffedb79.zip |
Fix a bug which prevented creating new users on mysql 5.7.6+ servers (introduced while fixing #2418) (see also #2229)
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPUserManager.m | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m index 3fe37ae7..8280242f 100644 --- a/Source/SPUserManager.m +++ b/Source/SPUserManager.m @@ -1078,10 +1078,21 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn"; NSString *idString; if(requiresPost576PasswordHandling) { - //copy the hash from the parent. if the parent password changes at the same time, updateUser: will take care of it afterwards - NSString *plugin = [[[user parent] valueForKey:@"plugin"] tickQuotedString]; - NSString *hash = [[[user parent] valueForKey:@"authentication_string"] tickQuotedString]; - idString = [NSString stringWithFormat:@"IDENTIFIED WITH %@ AS %@",plugin,hash]; + // there are three situations to cover here: + // 1) host added, parent user unchanged + // 2) host added, parent user password changed + // 3) host added, parent user is new + if([[user parent] valueForKey:@"originaluser"]) { + // 1 & 2: If the parent user already exists we always use the old password hash. if the parent password changes at the same time, updateUser: will take care of it afterwards + NSString *plugin = [[[user parent] valueForKey:@"plugin"] tickQuotedString]; + NSString *hash = [[[user parent] valueForKey:@"authentication_string"] tickQuotedString]; + idString = [NSString stringWithFormat:@"IDENTIFIED WITH %@ AS %@",plugin,hash]; + } + else { + // 3: If the user is new, we take the plaintext password value from the UI + NSString *password = [[[user parent] valueForKey:@"password"] tickQuotedString]; + idString = [NSString stringWithFormat:@"IDENTIFIED BY %@",password]; + } } else { BOOL passwordIsHash; |