mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-07 20:30:41 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user