diff --git a/options_test.go b/options_test.go index 8d8fdf8..3b2f19f 100644 --- a/options_test.go +++ b/options_test.go @@ -15,6 +15,7 @@ func testOptions() *Options { o.CookieSecret = "foobar" o.ClientID = "bazquux" o.ClientSecret = "xyzzyplugh" + o.EmailDomains = []string{"*"} return o } @@ -27,6 +28,7 @@ func errorMsg(msgs []string) string { func TestNewOptions(t *testing.T) { o := NewOptions() + o.EmailDomains = []string{"*"} err := o.Validate() assert.NotEqual(t, nil, err) diff --git a/providers/github.go b/providers/github.go index a76d755..c9b490f 100644 --- a/providers/github.go +++ b/providers/github.go @@ -2,7 +2,6 @@ package providers import ( "encoding/json" - "errors" "fmt" "io/ioutil" "log" @@ -211,5 +210,5 @@ func (p *GitHubProvider) GetEmailAddress(s *SessionState) (string, error) { } } - return "", errors.New("no email address found") + return "", nil } diff --git a/providers/linkedin.go b/providers/linkedin.go index 78ad3c9..2151229 100644 --- a/providers/linkedin.go +++ b/providers/linkedin.go @@ -3,7 +3,6 @@ package providers import ( "errors" "fmt" - "log" "net/http" "net/url" @@ -60,13 +59,11 @@ func (p *LinkedInProvider) GetEmailAddress(s *SessionState) (string, error) { json, err := api.Request(req) if err != nil { - log.Printf("failed making request %s", err) return "", err } email, err := json.String() if err != nil { - log.Printf("failed making request %s", err) return "", err } return email, nil diff --git a/validator.go b/validator.go index 396e605..e3c0a54 100644 --- a/validator.go +++ b/validator.go @@ -71,9 +71,11 @@ func newValidatorImpl(domains []string, usersFile string, domains[i] = fmt.Sprintf("@%s", strings.ToLower(domain)) } - validator := func(email string) bool { + validator := func(email string) (valid bool) { + if email == "" { + return + } email = strings.ToLower(email) - valid := false for _, domain := range domains { valid = valid || strings.HasSuffix(email, domain) }