diff options
author | Alan McGovern <alan.mcgovern@gmail.com> | 2012-03-12 15:17:05 +0400 |
---|---|---|
committer | Alan McGovern <alan.mcgovern@gmail.com> | 2012-03-12 15:17:05 +0400 |
commit | 64c44ad3460a1d3a2a7f2f23c00263ee7fd9771e (patch) | |
tree | cc4f6697b5a4756af116150149b34a1dfece8d1a /main/src/addins/VersionControl | |
parent | d4328e52591346be45579951b3b6c162728c55fe (diff) |
[VersionControl] Use NGits new api for resetting bad passwords properly
This can remove the hack we were previously using which guessed if the password
was probably incorrect based on a timestamp.
Diffstat (limited to 'main/src/addins/VersionControl')
-rw-r--r-- | main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitCredentials.cs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitCredentials.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitCredentials.cs index 525c0d2610..a3f1e5d0f4 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitCredentials.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitCredentials.cs @@ -35,7 +35,7 @@ namespace MonoDevelop.VersionControl.Git { public class GitCredentials: CredentialsProvider { - DateTime LastAsked { + bool HasReset { get; set; } @@ -60,8 +60,7 @@ namespace MonoDevelop.VersionControl.Git 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 (!ProbablyIncorrect ()) { - LastAsked = DateTime.Now; + if (!HasReset) { return true; } } @@ -75,7 +74,7 @@ namespace MonoDevelop.VersionControl.Git } }); - LastAsked = DateTime.Now; + HasReset = false; if (result) { if (passwordItem != null) { PasswordService.AddWebPassword (new Uri (uri.ToString ()), new string (passwordItem.GetValue ())); @@ -86,11 +85,9 @@ namespace MonoDevelop.VersionControl.Git return result; } - bool ProbablyIncorrect () + public override void Reset (URIish uri) { - // If we are queried multiple times in rapid succession it is probably - // because the supplied password is incorrect and we should dump it. - return (DateTime.Now - LastAsked) < TimeSpan.FromSeconds (2); + HasReset = true; } bool TryGetPassphrase (URIish uri, CredentialItem[] items, out CredentialItem.StringType passphraseItem) |