From 92b9f5d4c025c6bd50367d6a2e9b39e257769107 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Tue, 23 Mar 2010 13:30:26 +0000 Subject: Before opening the user manager check that the current user has access to the mysql.user table. If they don't display a warning message that they don't have the necessary privileges for user management. --- Source/TableDocument.m | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Source') diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 797631e3..ac076c8b 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -2302,6 +2302,24 @@ */ - (IBAction)showUserManager:(id)sender { + // Before displaying the user manager make sure the current user has access to the mysql.user table. + MCPResult *result = [mySQLConnection queryString:@"SELECT * FROM `mysql`.`user` ORDER BY `user`"]; + + if ((![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) && ([result numOfRows] == 0)) { + + NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Unable to get list of users", @"unable to get list of users message") + defaultButton:NSLocalizedString(@"OK", @"OK button") + alternateButton:nil + otherButton:nil + informativeTextWithFormat:NSLocalizedString(@"An error occurred while trying to get the list of users. Please make sure you have the necessary privileges to perform user management, including access to the mysql.user table.", @"unable to get list of users informative message")]; + + [alert setAlertStyle:NSCriticalAlertStyle]; + + [alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"cannotremovefield"]; + + return; + } + [NSApp beginSheet:[userManagerInstance window] modalForWindow:tableWindow modalDelegate:userManagerInstance -- cgit v1.2.3