improved error messaging in Github's GetLogin

This commit is contained in:
Brad Rydzewski 2014-09-08 23:09:00 -07:00
parent 78cc56977a
commit 9455dbab9f
2 changed files with 3 additions and 3 deletions

View file

@ -81,13 +81,13 @@ func (r *GitHub) Authorize(res http.ResponseWriter, req *http.Request) (*model.L
var trans = &oauth.Transport{Config: config} var trans = &oauth.Transport{Config: config}
var token, err = trans.Exchange(code) var token, err = trans.Exchange(code)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("Error exchanging token. %s", err)
} }
var client = NewClient(r.API, token.AccessToken) var client = NewClient(r.API, token.AccessToken)
var useremail, errr = GetUserEmail(client) var useremail, errr = GetUserEmail(client)
if errr != nil { if errr != nil {
return nil, errr return nil, fmt.Errorf("Error retrieving user or verified email. %s", errr)
} }
var login = new(model.Login) var login = new(model.Login)
@ -95,7 +95,6 @@ func (r *GitHub) Authorize(res http.ResponseWriter, req *http.Request) (*model.L
login.Access = token.AccessToken login.Access = token.AccessToken
login.Login = *useremail.Login login.Login = *useremail.Login
login.Email = *useremail.Email login.Email = *useremail.Email
login.Name = *useremail.Email
if useremail.Name != nil { if useremail.Name != nil {
login.Name = *useremail.Name login.Name = *useremail.Name
} }

View file

@ -44,6 +44,7 @@ func registerGitHubEnterprise() {
len(*githubEnterpriseSecret) == 0 { len(*githubEnterpriseSecret) == 0 {
return return
} }
remote.Register( remote.Register(
New( New(
*githubEnterpriseURL, *githubEnterpriseURL,