(ctx context.Context, username, accessToken string)
| 313 | } |
| 314 | |
| 315 | func (p *GitHubProvider) isCollaborator(ctx context.Context, username, accessToken string) (bool, error) { |
| 316 | //https://developer.github.com/v3/repos/collaborators/#check-if-a-user-is-a-collaborator |
| 317 | |
| 318 | endpoint := p.makeGitHubAPIEndpoint("/repos/"+p.Repo+"/collaborators/"+username, nil) |
| 319 | result := requests.New(endpoint.String()). |
| 320 | WithContext(ctx). |
| 321 | WithHeaders(makeGitHubHeader(accessToken)). |
| 322 | Do() |
| 323 | if result.Error() != nil { |
| 324 | return false, result.Error() |
| 325 | } |
| 326 | |
| 327 | if result.StatusCode() != 204 { |
| 328 | return false, fmt.Errorf("got %d from %q %s", |
| 329 | result.StatusCode(), endpoint.String(), result.Body()) |
| 330 | } |
| 331 | |
| 332 | logger.Printf("got %d from %q %s", result.StatusCode(), endpoint.String(), result.Body()) |
| 333 | |
| 334 | return true, nil |
| 335 | } |
| 336 | |
| 337 | // getEmail updates the SessionState Email |
| 338 | func (p *GitHubProvider) getEmail(ctx context.Context, s *sessions.SessionState) error { |
no test coverage detected