(ctx context.Context, accessToken string)
| 288 | } |
| 289 | |
| 290 | func (p *GitHubProvider) hasUser(ctx context.Context, accessToken string) (bool, error) { |
| 291 | // https://developer.github.com/v3/users/#get-the-authenticated-user |
| 292 | |
| 293 | var user struct { |
| 294 | Login string `json:"login"` |
| 295 | Email string `json:"email"` |
| 296 | } |
| 297 | |
| 298 | endpoint := p.makeGitHubAPIEndpoint("/user", nil) |
| 299 | |
| 300 | err := requests.New(endpoint.String()). |
| 301 | WithContext(ctx). |
| 302 | WithHeaders(makeGitHubHeader(accessToken)). |
| 303 | Do(). |
| 304 | UnmarshalInto(&user) |
| 305 | if err != nil { |
| 306 | return false, err |
| 307 | } |
| 308 | |
| 309 | if p.isVerifiedUser(user.Login) { |
| 310 | return true, nil |
| 311 | } |
| 312 | return false, nil |
| 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 |
no test coverage detected