Skip to content

Commit

Permalink
avoid panic in case of invalid repons from google
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Mancke committed Aug 17, 2017
1 parent 4885ce5 commit 51f4e57
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions oauth2/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ var providerGoogle = Provider{
return model.UserInfo{}, "", fmt.Errorf("error parsing google get user info: %v", err)
}

if len(gu.Emails) == 0 {
return model.UserInfo{}, "", fmt.Errorf("invalid google response: no email address returned.", err)
}

return model.UserInfo{
Sub: gu.Emails[0].Value,
Picture: gu.Image.Url,
Expand Down

0 comments on commit 51f4e57

Please sign in to comment.