aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPUserManager.m
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2016-03-03 22:38:41 +0100
committerMax <post@wickenrode.com>2016-03-03 22:38:41 +0100
commit0ac1ebf15c11f4b283a3d8a001b41f568c491876 (patch)
tree1371807b9be1d339997fba2221a217a54c91bf0e /Source/SPUserManager.m
parentbff1773bf4eeb79fc74e42cab68a98518f5a3198 (diff)
downloadsequelpro-0ac1ebf15c11f4b283a3d8a001b41f568c491876.tar.gz
sequelpro-0ac1ebf15c11f4b283a3d8a001b41f568c491876.tar.bz2
sequelpro-0ac1ebf15c11f4b283a3d8a001b41f568c491876.zip
Fix an issue where changing a user password and adding a host at the same time would result in a query error (#2427)
Diffstat (limited to 'Source/SPUserManager.m')
-rw-r--r--Source/SPUserManager.m20
1 files changed, 18 insertions, 2 deletions
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m
index a5a83cbe..12da17fb 100644
--- a/Source/SPUserManager.m
+++ b/Source/SPUserManager.m
@@ -1084,8 +1084,24 @@ static NSString * const SPTableViewNameColumnID = @"NameColumn";
idString = [NSString stringWithFormat:@"IDENTIFIED WITH %@ AS %@",plugin,hash];
}
else {
- NSString *password = [[[user parent] valueForKey:@"password"] tickQuotedString];
- idString = [NSString stringWithFormat:@"IDENTIFIED BY %@%@",[[user parent] valueForKey:@"originaluser"]?@"PASSWORD ":@"", password];
+ BOOL passwordIsHash;
+ NSString *password;
+ // 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.
+ // This works because -updateUser: will be called after -insertUser: and update the password for this host, anyway.
+ passwordIsHash = YES;
+ password = [[[user parent] valueForKey:@"originalpassword"] tickQuotedString];
+ }
+ else {
+ // 3: If the user is new, we take the plaintext password value from the UI
+ passwordIsHash = NO;
+ password = [[[user parent] valueForKey:@"password"] tickQuotedString];
+ }
+ idString = [NSString stringWithFormat:@"IDENTIFIED BY %@%@",(passwordIsHash? @"PASSWORD " : @""), password];
}
createStatement = ([serverSupport supportsCreateUser]) ?