aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2011-10-20 23:34:52 +0000
committerrowanbeentje <rowan@beent.je>2011-10-20 23:34:52 +0000
commit6c8e8f9e66d76858e76b8a391aa51d161801ed43 (patch)
tree8efc1367a46431dc10472c4ed59a193afece314c /Source
parent57fd5f88863ffec21159f132670efac343c5d48d (diff)
downloadsequelpro-6c8e8f9e66d76858e76b8a391aa51d161801ed43.tar.gz
sequelpro-6c8e8f9e66d76858e76b8a391aa51d161801ed43.tar.bz2
sequelpro-6c8e8f9e66d76858e76b8a391aa51d161801ed43.zip
- Fix addition of new passwords for favourites edited via the Preferences interface. This addresses Issue #1214.
Diffstat (limited to 'Source')
-rw-r--r--Source/SPFavoritesPreferencePane.m18
1 files changed, 14 insertions, 4 deletions
diff --git a/Source/SPFavoritesPreferencePane.m b/Source/SPFavoritesPreferencePane.m
index c009f8e3..4f640f11 100644
--- a/Source/SPFavoritesPreferencePane.m
+++ b/Source/SPFavoritesPreferencePane.m
@@ -860,11 +860,16 @@
if (![passwordValue length]) {
[keychain deletePasswordForName:oldKeychainName account:oldKeychainAccount];
- // Otherwise, set up the new keychain name and account strings and edit the item
+ // Otherwise, set up the new keychain name and account strings and create or edit the item
} else {
newKeychainName = [keychain nameForFavoriteName:[favoritesController valueForKeyPath:@"selection.name"] id:[favoritesController valueForKeyPath:@"selection.id"]];
newKeychainAccount = [keychain accountForUser:[favoritesController valueForKeyPath:@"selection.user"] host:newHostnameForPassword database:[favoritesController valueForKeyPath:@"selection.database"]];
- [keychain updateItemWithName:oldKeychainName account:oldKeychainAccount toName:newKeychainName account:newKeychainAccount password:passwordValue];
+ if ([keychain passwordExistsForName:oldKeychainName account:oldKeychainAccount]) {
+ [keychain updateItemWithName:oldKeychainName account:oldKeychainAccount toName:newKeychainName account:newKeychainAccount password:passwordValue];
+ } else {
+ [keychain addPassword:passwordValue forName:newKeychainName account:newKeychainAccount];
+ }
+
}
// Synch password changes
@@ -889,11 +894,16 @@
if (![[sshPasswordField stringValue] length]) {
[keychain deletePasswordForName:oldKeychainName account:oldKeychainAccount];
- // Otherwise, set up the new keychain name and account strings and update the keychain item
+
+ // Otherwise, set up the new keychain name and account strings and create or update the keychain item
} else {
newKeychainName = [keychain nameForSSHForFavoriteName:[favoritesController valueForKeyPath:@"selection.name"] id:[favoritesController valueForKeyPath:@"selection.id"]];
newKeychainAccount = [keychain accountForSSHUser:[favoritesController valueForKeyPath:@"selection.sshUser"] sshHost:[favoritesController valueForKeyPath:@"selection.sshHost"]];
- [keychain updateItemWithName:oldKeychainName account:oldKeychainAccount toName:newKeychainName account:newKeychainAccount password:[sshPasswordField stringValue]];
+ if ([keychain passwordExistsForName:oldKeychainName account:oldKeychainAccount]) {
+ [keychain updateItemWithName:oldKeychainName account:oldKeychainAccount toName:newKeychainName account:newKeychainAccount password:[sshPasswordField stringValue]];
+ } else {
+ [keychain addPassword:[sshPasswordField stringValue] forName:newKeychainName account:newKeychainAccount];
+ }
}
}