mirror of
https://github.com/wahyd4/loginsrv.git
synced 2026-08-09 04:46:29 +10:00
strip parameters from image url since they are added later
This commit is contained in:
+4
-1
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user