From 8affa39a68350f0fa786d63ba4cb72ce88bcdec3 Mon Sep 17 00:00:00 2001 From: Meutel Date: Wed, 11 Sep 2019 17:26:32 +0200 Subject: [PATCH] Fix vet --- bouquins/gitea.go | 8 ++++++-- bouquins/github.go | 2 +- bouquins/google.go | 2 +- go.sum | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bouquins/gitea.go b/bouquins/gitea.go index 808da3c..37a34cc 100644 --- a/bouquins/gitea.go +++ b/bouquins/gitea.go @@ -61,7 +61,11 @@ func (p GiteaProvider) Config(conf *Conf) *oauth2.Config { ClientID: c.ClientID, ClientSecret: c.ClientSecret, RedirectURL: conf.ExternalURL + "/callback", - Endpoint: oauth2.Endpoint{c.AuthURL, c.TokenURL, oauth2.AuthStyleAutoDetect}, + Endpoint: oauth2.Endpoint{ + AuthURL: c.AuthURL, + TokenURL: c.TokenURL, + AuthStyle: oauth2.AuthStyleAutoDetect, + }, } } } @@ -75,11 +79,11 @@ func (p GiteaProvider) GetUser(app *Bouquins, token *oauth2.Token) (string, erro apiReq.Header.Add("Authorization", "token "+token.AccessToken) client := &http.Client{} response, err := client.Do(apiReq) - defer response.Body.Close() if err != nil { log.Println("Auth error", err) return "", fmt.Errorf("Authentification error") } + defer response.Body.Close() dec := json.NewDecoder(response.Body) var profile giteaProfile diff --git a/bouquins/github.go b/bouquins/github.go index 0a6d6ed..c7b87a7 100644 --- a/bouquins/github.go +++ b/bouquins/github.go @@ -61,11 +61,11 @@ func (p GithubProvider) GetUser(app *Bouquins, token *oauth2.Token) (string, err apiReq.Header.Add("Authorization", "token "+token.AccessToken) client := &http.Client{} response, err := client.Do(apiReq) - defer response.Body.Close() if err != nil { log.Println("Auth error", err) return "", fmt.Errorf("Authentification error") } + defer response.Body.Close() dec := json.NewDecoder(response.Body) var emails []githubEmail diff --git a/bouquins/google.go b/bouquins/google.go index cebd669..8c1124e 100644 --- a/bouquins/google.go +++ b/bouquins/google.go @@ -62,11 +62,11 @@ func (p GoogleProvider) Config(conf *Conf) *oauth2.Config { // GetUser returns github primary email func (p GoogleProvider) GetUser(app *Bouquins, token *oauth2.Token) (string, error) { apiRes, err := http.Post("https://www.googleapis.com/oauth2/v2/tokeninfo?access_token="+token.AccessToken, "application/json", nil) - defer apiRes.Body.Close() if err != nil { log.Println("Auth error", err) return "", fmt.Errorf("Authentification error") } + defer apiRes.Body.Close() dec := json.NewDecoder(apiRes.Body) var tokenInfo googleTokenInfo err = dec.Decode(&tokenInfo) diff --git a/go.sum b/go.sum index 2dbdc20..4b63630 100644 --- a/go.sum +++ b/go.sum @@ -16,6 +16,7 @@ golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=