strip parameters from image url since they are added later

This commit is contained in:
luke.hopkins
2017-10-19 17:04:49 +01:00
parent d85b02c5cd
commit 29cfa85464
2 changed files with 5 additions and 1 deletions
+4 -1
View File
@@ -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",
+1
View File
@@ -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)