Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
8f9eeb5e
Commit
8f9eeb5e
authored
May 29, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2067 from bcandrea/private-email-in-github-oauth
Use private email address in GitHub OAUTH
parents
db2ff68f
cf147cde
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
pkg/social/social.go
+38
-0
No files found.
pkg/social/social.go
View file @
8f9eeb5e
...
@@ -186,6 +186,37 @@ func (s *SocialGithub) IsOrganizationMember(client *http.Client) bool {
...
@@ -186,6 +186,37 @@ func (s *SocialGithub) IsOrganizationMember(client *http.Client) bool {
return
false
return
false
}
}
func
(
s
*
SocialGithub
)
FetchPrivateEmail
(
client
*
http
.
Client
)
(
string
,
error
)
{
type
Record
struct
{
Email
string
`json:"email"`
Primary
bool
`json:"primary"`
Verified
bool
`json:"verified"`
}
emailsUrl
:=
fmt
.
Sprintf
(
"https://api.github.com/user/emails"
)
r
,
err
:=
client
.
Get
(
emailsUrl
)
if
err
!=
nil
{
return
""
,
err
}
defer
r
.
Body
.
Close
()
var
records
[]
Record
if
err
=
json
.
NewDecoder
(
r
.
Body
)
.
Decode
(
&
records
);
err
!=
nil
{
return
""
,
err
}
var
email
=
""
for
_
,
record
:=
range
records
{
if
record
.
Primary
{
email
=
record
.
Email
}
}
return
email
,
nil
}
func
(
s
*
SocialGithub
)
FetchTeamMemberships
(
client
*
http
.
Client
)
([]
int
,
error
)
{
func
(
s
*
SocialGithub
)
FetchTeamMemberships
(
client
*
http
.
Client
)
([]
int
,
error
)
{
type
Record
struct
{
type
Record
struct
{
Id
int
`json:"id"`
Id
int
`json:"id"`
...
@@ -274,6 +305,13 @@ func (s *SocialGithub) UserInfo(token *oauth2.Token) (*BasicUserInfo, error) {
...
@@ -274,6 +305,13 @@ func (s *SocialGithub) UserInfo(token *oauth2.Token) (*BasicUserInfo, error) {
return
nil
,
ErrMissingOrganizationMembership
return
nil
,
ErrMissingOrganizationMembership
}
}
if
userInfo
.
Email
==
""
{
userInfo
.
Email
,
err
=
s
.
FetchPrivateEmail
(
client
)
if
err
!=
nil
{
return
nil
,
err
}
}
return
userInfo
,
nil
return
userInfo
,
nil
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment