Skip to content

Commit 2a79403

Browse files
committed
github: fix bug passing username hint to cred lookup
In adding support for multiple-user accounts for GitHub we introduced a bug that would mean we ignored a username-hint provided by Git/remote URL when looking up an existing credential. The result is that we'd return _any_ credential rather than specifically one for the desired account! Fix this by always passing the input username hint when first evaluating which user account to select.
1 parent ae15915 commit 2a79403

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/shared/GitHub/GitHubHostProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ public async Task<ICredential> GetCredentialAsync(InputArguments input)
132132
// If we have a specific username then we can try and find an existing credential for that account.
133133
// If not, we should check what accounts are available in the store and prompt the user if there
134134
// are multiple options.
135-
string userName = null;
135+
string userName = input.UserName;
136136
bool addAccount = false;
137-
if (string.IsNullOrWhiteSpace(input.UserName))
137+
if (string.IsNullOrWhiteSpace(userName))
138138
{
139139
IList<string> accounts = _context.CredentialStore.GetAccounts(service);
140140
_context.Trace.WriteLine($"Found {accounts.Count} accounts in the store for service={service}.");
@@ -172,7 +172,7 @@ public async Task<ICredential> GetCredentialAsync(InputArguments input)
172172

173173
// No existing credential was found, create a new one
174174
_context.Trace.WriteLine("Creating new credential...");
175-
credential = await GenerateCredentialAsync(remoteUri, input.UserName);
175+
credential = await GenerateCredentialAsync(remoteUri, userName);
176176
_context.Trace.WriteLine("Credential created.");
177177
}
178178
else

0 commit comments

Comments
 (0)