Skip to content

Commit

Permalink
Merge pull request #111 from lipkau/fix/TestForCaptcha
Browse files Browse the repository at this point in the history
Add test if headers contain info that captcha is required
  • Loading branch information
replicaJunction authored Jun 6, 2017
2 parents 328c90e + 72c0f71 commit 60ff34c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions PSJira/Public/New-JiraSession.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ function New-JiraSession
$webResponse = $err.Exception.Response
Write-Debug "[New-JiraSession] Encountered an exception from the Jira server: $err"

# Test HEADERS if Jira requires a CAPTCHA
$tokenRequiresCaptcha = "AUTHENTICATION_DENIED"
$headerRequiresCaptcha = "X-Seraph-LoginReason"
if (($webResponse.Headers[$headerRequiresCaptcha] -split ",") -contains $tokenRequiresCaptcha) {
Write-Warning "JIRA requires you to log on to the website before continuing for security reasons."
}

Write-Warning "JIRA returned HTTP error $($webResponse.StatusCode.value__) - $($webResponse.StatusCode)"

# Retrieve body of HTTP response - this contains more useful information about exactly why the error
Expand Down

0 comments on commit 60ff34c

Please sign in to comment.