Add more info to TwoFactorChallengeFailedException

I was running into an issue where i wanted more information from the
TwoFactorChallengeFailedException. It turns out, the exception could
easily provide both the TwoFactorType AND the authentication code
provided. So 💥!
This commit is contained in:
Haacked
2015-04-19 19:42:13 -07:00
parent 518ae12080
commit 93dd16f829
12 changed files with 155 additions and 54 deletions
+2 -2
View File
@@ -489,9 +489,9 @@ namespace Octokit
: new ForbiddenException(response);
}
static TwoFactorType ParseTwoFactorType(IResponse restResponse)
internal static TwoFactorType ParseTwoFactorType(IResponse restResponse)
{
if (restResponse.Headers == null || !restResponse.Headers.Any()) return TwoFactorType.None;
if (restResponse == null || restResponse.Headers == null || !restResponse.Headers.Any()) return TwoFactorType.None;
var otpHeader = restResponse.Headers.FirstOrDefault(header =>
header.Key.Equals("X-GitHub-OTP", StringComparison.OrdinalIgnoreCase));
if (String.IsNullOrEmpty(otpHeader.Value)) return TwoFactorType.None;