Skip to content
This repository has been archived by the owner on Jan 24, 2019. It is now read-only.

Commit

Permalink
Revert "Ignore spaces in authorized emails list"
Browse files Browse the repository at this point in the history
This reverts commit 059dcbf.
  • Loading branch information
Ruta Sakalauskaite authored and Ruta Sakalauskaite committed Jan 21, 2016
1 parent bd77857 commit a5b111c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
6 changes: 3 additions & 3 deletions providers/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (p *GitHubProvider) hasOrg(accessToken string) (bool, error) {
"limit": {"100"},
}

endpoint := p.ValidateURL.Scheme + "://" + p.ValidateURL.Host + "/user/orgs?" + params.Encode()
endpoint := "https://api.github.com/user/orgs?" + params.Encode()
req, _ := http.NewRequest("GET", endpoint, nil)
req.Header.Set("Accept", "application/vnd.github.v3+json")
resp, err := http.DefaultClient.Do(req)
Expand Down Expand Up @@ -113,7 +113,7 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
"limit": {"100"},
}

endpoint := p.ValidateURL.Scheme + "://" + p.ValidateURL.Host + "/user/teams?" + params.Encode()
endpoint := "https://api.github.com/user/teams?" + params.Encode()
req, _ := http.NewRequest("GET", endpoint, nil)
req.Header.Set("Accept", "application/vnd.github.v3+json")
resp, err := http.DefaultClient.Do(req)
Expand Down Expand Up @@ -183,7 +183,7 @@ func (p *GitHubProvider) GetEmailAddress(s *SessionState) (string, error) {
params := url.Values{
"access_token": {s.AccessToken},
}
endpoint := p.ValidateURL.Scheme + "://" + p.ValidateURL.Host + p.ValidateURL.Path + "?" + params.Encode()
endpoint := "https://api.github.com/user/emails?" + params.Encode()
resp, err := http.DefaultClient.Get(endpoint)
if err != nil {
return "", err
Expand Down
3 changes: 1 addition & 2 deletions validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ func (um *UserMap) LoadAuthenticatedEmailsFile() {
}
updated := make(map[string]bool)
for _, r := range records {
address := strings.ToLower(strings.TrimSpace(r[0]))
updated[address] = true
updated[strings.ToLower(r[0])] = true
}
atomic.StorePointer(&um.m, unsafe.Pointer(&updated))
}
Expand Down
13 changes: 0 additions & 13 deletions validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,3 @@ func TestValidatorComparisonsAreCaseInsensitive(t *testing.T) {
t.Error("validated domains are not lower-cased")
}
}

func TestValidatorIgnoreSpacesInAuthEmails(t *testing.T) {
vt := NewValidatorTest(t)
defer vt.TearDown()

vt.WriteEmails(t, []string{" foo.bar@example.com "})
domains := []string(nil)
validator := vt.NewValidator(domains, nil)

if !validator("foo.bar@example.com") {
t.Error("email should validate")
}
}

0 comments on commit a5b111c

Please sign in to comment.