[mono/monodevelop] e87a12cf: [Git] Properly fix keychain saving

"Ungureanu Marius ([email protected])" <[email protected]> Wed, 20 Nov 2013 23:24:53 +0000
Newsgroups gmane.comp.gnome.mono.patches
Message-ID <0000014277d4a2b7-ff24ebb4-e86e-4880-968a-b1972c08d488-000000@email.amazonses.com>
   Branch: refs/heads/master
     Home: https://github.com/mono/monodevelop
  Compare: https://github.com/mono/monodevelop/compare/dae3c0cb7d36...e87a12cfbf5a

   Commit: e87a12cfbf5a14cebf345974393d9a87dc81ee77
   Author: Ungureanu Marius <[email protected]> (Therzok)
     Date: 2013-11-20 23:22:43 GMT
      URL: https://github.com/mono/monodevelop/commit/e87a12cfbf5a14cebf345974393d9a87dc81ee77

[Git] Properly fix keychain saving

Damn you hackfix!

Changed paths:
  M main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitCredentials.cs

Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitCredentials.cs
===================================================================
@@ -56,7 +56,7 @@ public override bool Get (URIish uri, params CredentialItem[] items)
 			
 			// We always need to run the TryGet* methods as we need the passphraseItem/passwordItem populated even
 			// if the password store contains an invalid password/no password
-			if (/*TryGetUsernamePassword (uri, items, out passwordItem) || */TryGetPassphrase (uri, items, out passphraseItem)) {
+			if (TryGetUsernamePassword (uri, items, out passwordItem) || TryGetPassphrase (uri, items, out passphraseItem)) {
 				// If the password store has a password and we already tried using it, it could be incorrect.
 				// If this happens, do not return true and ask the user for a new password.
 				if (!HasReset) {
@@ -75,9 +75,10 @@ public override bool Get (URIish uri, params CredentialItem[] items)
 				
 			HasReset = false;
 			if (result) {
-				/*if (passwordItem != null) {
-					PasswordService.AddWebPassword (new Uri (uri.ToString ()), new string (passwordItem.GetValue ()));
-				} else*/ if (passphraseItem != null) {
+				var user = items.OfType<CredentialItem.Username> ().FirstOrDefault ();
+				if (passwordItem != null) {
+					PasswordService.AddWebUserNameAndPassword (new Uri (uri.ToString ()), user.GetValue (), new string (passwordItem.GetValue ()));
+				} else if (passphraseItem != null) {
 					PasswordService.AddWebPassword (new Uri (uri.ToString ()), passphraseItem.GetValue ());
 				}
 			}
@@ -118,10 +119,10 @@ static bool TryGetUsernamePassword (URIish uri, CredentialItem[] items, out Cred
 			if (items.Length == 2 && username != null && password != null) {
 				passwordItem = password;
 
-				var passwordValue = PasswordService.GetWebPassword (actualUrl);
-				if (passwordValue != null) {
-					username.SetValue (actualUrl.UserInfo);
-					password.SetValueNoCopy (passwordValue.ToArray ());
+				var cred = PasswordService.GetWebUserNameAndPassword (actualUrl);
+				if (cred != null) {
+					username.SetValue (cred.Item1);
+					password.SetValueNoCopy (cred.Item2.ToArray ());
 					return true;
 				}
 			} else {


_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches