Skip to content

Commit

Permalink
Merge pull request #508 from penberg/github-explicit-email-error
Browse files Browse the repository at this point in the history
github: Add ErrNoVerifiedGitHubPrimaryEmail error
  • Loading branch information
techknowlogick committed May 7, 2023
2 parents 8333bec + 22a3c4d commit 4929279
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion providers/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ var (
EmailURL = "https://api.github.com/user/emails"
)

var (
// ErrNoVerifiedGitHubPrimaryEmail user doesn't have verified primary email on GitHub
ErrNoVerifiedGitHubPrimaryEmail = errors.New("The user does not have a verified, primary email address on GitHub")
)

// New creates a new Github provider, and sets up important connection details.
// You should always call `github.New` to get a new Provider. Never try to create
// one manually.
Expand Down Expand Up @@ -207,7 +212,7 @@ func getPrivateMail(p *Provider, sess *Session) (email string, err error) {
return v.Email, nil
}
}
return email, fmt.Errorf("The user does not have a verified, primary email address on GitHub")
return email, ErrNoVerifiedGitHubPrimaryEmail
}

func newConfig(provider *Provider, authURL, tokenURL string, scopes []string) *oauth2.Config {
Expand Down

0 comments on commit 4929279

Please sign in to comment.