loginsrv

Unnamed repository; edit this file 'description' to name the repository.
git clone git@jamesshield.xyz:repos/loginsrv.git
Log | Files | Refs | README | LICENSE

commit a4c2464c6274de64e68d18064b4de1056e3b95f3
parent bec362a3158db9312bb26a614c167e9ea5379484
Author: Sebastian Mancke <s.mancke@tarent.de>
Date:   Mon, 23 Oct 2017 10:42:41 +0200

Merge pull request #49 from lhopki01/master

Fix issues with picture display
Diffstat:
Mlogin/login_form.go | 6++++--
Moauth2/google.go | 5++++-
Moauth2/google_test.go | 1+
3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/login/login_form.go b/login/login_form.go @@ -2,12 +2,13 @@ package login import ( "bytes" - "github.com/tarent/loginsrv/logging" - "github.com/tarent/loginsrv/model" "html/template" "io/ioutil" "net/http" "strings" + + "github.com/tarent/loginsrv/logging" + "github.com/tarent/loginsrv/model" ) const partials = ` @@ -46,6 +47,7 @@ const partials = ` width: 120px; height: 120px; border-radius: 3px; + margin-bottom: 10px; } </style> {{end}} diff --git a/oauth2/google.go b/oauth2/google.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "net/http" + "regexp" "strings" "github.com/tarent/loginsrv/model" @@ -62,9 +63,11 @@ var providerGoogle = Provider{ return model.UserInfo{}, "", fmt.Errorf("invalid google response: no email address returned.") } + reg := regexp.MustCompile(`\?.*$`) + return model.UserInfo{ Sub: gu.Emails[0].Value, - Picture: gu.Image.Url, + Picture: reg.ReplaceAllString(gu.Image.Url, "${1}"), Name: gu.DisplayName, Email: gu.Emails[0].Value, Origin: "google", diff --git a/oauth2/google_test.go b/oauth2/google_test.go @@ -50,6 +50,7 @@ func Test_Google_getUserInfo(t *testing.T) { NoError(t, err) Equal(t, "test@gmail.com", u.Sub) Equal(t, "test@gmail.com", u.Email) + Equal(t, "https://lh3.googleusercontent.com/X/X/X/X/photo.jpg", u.Picture) Equal(t, "Testy Test", u.Name) Equal(t, "gmail.com", u.Domain) Equal(t, googleTestUserResponse, rawJSON)