From b704e9489b21b3bec17f5c8b573a1724781ee6f7 Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Fri, 14 Aug 2015 08:43:49 -0400 Subject: added google sign-in functionality to the client, with minor model modifications --- model/google.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'model') diff --git a/model/google.go b/model/google.go index bdb500704..2a1eb3caa 100644 --- a/model/google.go +++ b/model/google.go @@ -6,6 +6,7 @@ package model import ( "encoding/json" "io" + "strings" ) const ( @@ -13,15 +14,20 @@ const ( ) type GoogleUser struct { - Id string `json:"id"` - Nickname string `json:"nickname"` - Emails []map[string]string `json:"emails"` - Names map[string]string `json:"name"` + Id string `json:"id"` + Nickname string `json:"nickname"` + DisplayName string `json:"displayName"` + Emails []map[string]string `json:"emails"` + Names map[string]string `json:"name"` } func UserFromGoogleUser(gu *GoogleUser) *User { user := &User{} - user.Username = gu.Nickname + if len(gu.Nickname) > 0 { + user.Username = gu.Nickname + } else { + user.Username = strings.ToLower(strings.Replace(gu.DisplayName, " ", "", -1)) + } user.FirstName = gu.Names["givenName"] user.LastName = gu.Names["familyName"] user.Nickname = gu.Nickname -- cgit v1.2.3-1-g7c22