aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPUserManager.m
diff options
context:
space:
mode:
authormltownsend <mltownsend@gmail.com>2009-12-07 21:54:14 +0000
committermltownsend <mltownsend@gmail.com>2009-12-07 21:54:14 +0000
commit73df7b3d9a91bb57319a6fa44e5c01656a4443aa (patch)
tree2122dc17b74a7188f364351e8643537bb09af8e1 /Source/SPUserManager.m
parenta3f0d1bfc942ad23c07465f6f3306e42b4ab0118 (diff)
downloadsequelpro-73df7b3d9a91bb57319a6fa44e5c01656a4443aa.tar.gz
sequelpro-73df7b3d9a91bb57319a6fa44e5c01656a4443aa.tar.bz2
sequelpro-73df7b3d9a91bb57319a6fa44e5c01656a4443aa.zip
Added ability to change the users password. Only does it for all hosts at once. This is the same behavior as other clients. If it is necessary to have a different password for each user/host combination, then we could probably do that. Just makes the UI a little confusing, IMO.
Diffstat (limited to 'Source/SPUserManager.m')
-rw-r--r--Source/SPUserManager.m31
1 files changed, 26 insertions, 5 deletions
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m
index 37824f47..067508c8 100644
--- a/Source/SPUserManager.m
+++ b/Source/SPUserManager.m
@@ -408,6 +408,7 @@
}
else {
// Close sheet
+ [self.mySqlConnection queryString:@"FLUSH PRIVILEGES"];
[NSApp endSheet:[self window] returnCode:0];
[[self window] orderOut:self];
}
@@ -610,7 +611,25 @@
- (BOOL)updateUsers:(NSArray *)updatedUsers
{
for (NSManagedObject *user in updatedUsers) {
- [self grantPrivilegesToUser:user];
+ if (![user host])
+ {
+ // Just the user password was changed.
+ // Change password to be the same on all hosts.
+ NSArray *hosts = [user valueForKey:@"children"];
+ for(NSManagedObject *child in hosts)
+ {
+ NSString *changePasswordStatement = [NSString stringWithFormat:
+ @"SET PASSWORD FOR %@@%@ = PASSWORD('%@')",
+ [[user valueForKey:@"user"] tickQuotedString],
+ [[child host] tickQuotedString],
+ [user valueForKey:@"password"]];
+ [self.mySqlConnection queryString:changePasswordStatement];
+ [self checkAndDisplayMySqlError];
+ }
+ } else {
+ [self grantPrivilegesToUser:user];
+ }
+
}
return YES;
@@ -642,22 +661,24 @@
{
for (NSManagedObject *user in insertedUsers)
{
+ NSString *createStatement;
+
if ([user parent] && [[user parent] valueForKey:@"user"] && [[user parent] valueForKey:@"password"]) {
- NSString *createStatement = [NSString stringWithFormat:@"CREATE USER %@@%@ IDENTIFIED BY %@;",
+ createStatement = [NSString stringWithFormat:@"CREATE USER %@@%@ IDENTIFIED BY %@;",
[[[user parent] valueForKey:@"user"] tickQuotedString],
[[user valueForKey:@"host"] tickQuotedString],
[[[user parent] valueForKey:@"password"] tickQuotedString]];
-
+
// Create user in database
[self.mySqlConnection queryString:[NSString stringWithFormat:createStatement]];
if ([self checkAndDisplayMySqlError]) {
[self grantPrivilegesToUser:user];
- }
+ }
}
+
}
-
return YES;
}