Skip to content

Commit

Permalink
put back
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincobain2000 committed Feb 9, 2024
1 parent 7fc3323 commit 20eb64c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions app/pkg/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,18 @@ func (g *Github) VerifyGithubToken(token, orgName, repoName, commit string) erro
return err
}

// on same commit, the response code is 422 which doesn't mean it is not authenticated
if resp.StatusCode == http.StatusUnauthorized ||
resp.StatusCode == http.StatusForbidden ||
resp.StatusCode == http.StatusBadRequest ||
resp.StatusCode == http.StatusNotFound ||
resp.StatusCode >= http.StatusInternalServerError {
if resp.StatusCode == 422 {
err := fmt.Errorf("github auth response code is unprocessable entity %d", resp.StatusCode)
g.log.Error(err)
return err
}
if resp.StatusCode >= 400 && resp.StatusCode < 500 {
err := fmt.Errorf("github auth response code is unauthorized %d", resp.StatusCode)
g.log.Error(err)
return err
}
// if response is not a redirect
if resp.StatusCode == http.StatusMovedPermanently || resp.StatusCode == http.StatusFound {
err := fmt.Errorf("github auth response code is redirect %d", resp.StatusCode)
if resp.StatusCode >= 500 {
err := fmt.Errorf("github auth response code is server error %d", resp.StatusCode)
g.log.Error(err)
return err
}
Expand Down

0 comments on commit 20eb64c

Please sign in to comment.