fix: should check if email is verified
This commit is contained in:
		
							parent
							
								
									056089bbcc
								
							
						
					
					
						commit
						b49aeb222b
					
				|  | @ -203,7 +203,7 @@ func (p *GitHubProvider) GetEmailAddress(s *SessionState) (string, error) { | ||||||
| 
 | 
 | ||||||
| 	var emails []struct { | 	var emails []struct { | ||||||
| 		Email    string `json:"email"` | 		Email    string `json:"email"` | ||||||
| 		Primary bool   `json:"primary"` | 		Verified bool   `json:"verified"` | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// if we require an Org or Team, check that first
 | 	// if we require an Org or Team, check that first
 | ||||||
|  | @ -248,7 +248,7 @@ func (p *GitHubProvider) GetEmailAddress(s *SessionState) (string, error) { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	for _, email := range emails { | 	for _, email := range emails { | ||||||
| 		if email.Primary { | 		if email.Verified { | ||||||
| 			return email.Email, nil | 			return email.Email, nil | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -97,7 +97,7 @@ func TestGitHubProviderOverrides(t *testing.T) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func TestGitHubProviderGetEmailAddress(t *testing.T) { | func TestGitHubProviderGetEmailAddress(t *testing.T) { | ||||||
| 	b := testGitHubBackend([]string{`[ {"email": "michael.bland@gsa.gov", "primary": true} ]`}) | 	b := testGitHubBackend([]string{`[ {"email": "michael.bland@gsa.gov", "verified": true} ]`}) | ||||||
| 	defer b.Close() | 	defer b.Close() | ||||||
| 
 | 
 | ||||||
| 	bURL, _ := url.Parse(b.URL) | 	bURL, _ := url.Parse(b.URL) | ||||||
|  | @ -111,8 +111,8 @@ func TestGitHubProviderGetEmailAddress(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| func TestGitHubProviderGetEmailAddressWithOrg(t *testing.T) { | func TestGitHubProviderGetEmailAddressWithOrg(t *testing.T) { | ||||||
| 	b := testGitHubBackend([]string{ | 	b := testGitHubBackend([]string{ | ||||||
| 		`[ {"email": "michael.bland@gsa.gov", "primary": true, "login":"testorg"} ]`, | 		`[ {"email": "michael.bland@gsa.gov", "verified": true, "login":"testorg"} ]`, | ||||||
| 		`[ {"email": "michael.bland1@gsa.gov", "primary": true, "login":"testorg1"} ]`, | 		`[ {"email": "michael.bland1@gsa.gov", "verified": true, "login":"testorg1"} ]`, | ||||||
| 		`[ ]`, | 		`[ ]`, | ||||||
| 	}) | 	}) | ||||||
| 	defer b.Close() | 	defer b.Close() | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue