Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix a bug which prevented creating new users on mysql 5.7.6+ servers …
…(introduced while fixing #2418) (see also #2229)
  • Loading branch information
dmoagx committed Dec 7, 2016
1 parent 56badea commit 7a3152a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Source/SPUserManager.m
Expand Up @@ -1078,10 +1078,21 @@ - (BOOL)insertUser:(SPUserMO *)user

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;
Expand Down

0 comments on commit 7a3152a

Please sign in to comment.