Improved code readability
This commit is contained in:
parent
c42b66bdcc
commit
44f3354729
@ -77,14 +77,14 @@ func InstallFacebookAuth(app *aero.Application) {
|
|||||||
client := config.Client(context.Background(), token)
|
client := config.Client(context.Background(), token)
|
||||||
|
|
||||||
// Fetch user data from Facebook
|
// Fetch user data from Facebook
|
||||||
resp, err := client.Get("https://graph.facebook.com/me?fields=email,first_name,last_name,gender")
|
response, err := client.Get("https://graph.facebook.com/me?fields=email,first_name,last_name,gender")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Failed requesting user data from Facebook", err)
|
return ctx.Error(http.StatusBadRequest, "Failed requesting user data from Facebook", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer resp.Body.Close()
|
defer response.Body.Close()
|
||||||
body, _ := ioutil.ReadAll(resp.Body)
|
body, _ := ioutil.ReadAll(response.Body)
|
||||||
|
|
||||||
// Construct a FacebookUser object
|
// Construct a FacebookUser object
|
||||||
fbUser := FacebookUser{}
|
fbUser := FacebookUser{}
|
||||||
|
@ -84,14 +84,14 @@ func InstallGoogleAuth(app *aero.Application) {
|
|||||||
client := config.Client(context.Background(), token)
|
client := config.Client(context.Background(), token)
|
||||||
|
|
||||||
// Fetch user data from Google
|
// Fetch user data from Google
|
||||||
resp, err := client.Get("https://www.googleapis.com/oauth2/v3/userinfo")
|
response, err := client.Get("https://www.googleapis.com/oauth2/v3/userinfo")
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Failed requesting user data from Google", err)
|
return ctx.Error(http.StatusBadRequest, "Failed requesting user data from Google", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer resp.Body.Close()
|
defer response.Body.Close()
|
||||||
data, _ := ioutil.ReadAll(resp.Body)
|
data, _ := ioutil.ReadAll(response.Body)
|
||||||
|
|
||||||
// Construct a GoogleUser object
|
// Construct a GoogleUser object
|
||||||
var googleUser GoogleUser
|
var googleUser GoogleUser
|
||||||
|
@ -80,15 +80,19 @@ func InstallTwitterAuth(app *aero.Application) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch user data from Twitter
|
// Fetch user data from Twitter
|
||||||
params := url.Values{"include_email": {"true"}, "skip_status": {"true"}}
|
params := url.Values{
|
||||||
resp, err := config.Get(nil, tokenCred, "https://api.twitter.com/1.1/account/verify_credentials.json", params)
|
"include_email": {"true"},
|
||||||
|
"skip_status": {"true"},
|
||||||
|
}
|
||||||
|
|
||||||
|
response, err := config.Get(nil, tokenCred, "https://api.twitter.com/1.1/account/verify_credentials.json", params)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Error(http.StatusBadRequest, "Failed requesting user data from Twitter", err)
|
return ctx.Error(http.StatusBadRequest, "Failed requesting user data from Twitter", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer resp.Body.Close()
|
defer response.Body.Close()
|
||||||
body, _ := ioutil.ReadAll(resp.Body)
|
body, _ := ioutil.ReadAll(response.Body)
|
||||||
|
|
||||||
// Construct a TwitterUser object
|
// Construct a TwitterUser object
|
||||||
twUser := TwitterUser{}
|
twUser := TwitterUser{}
|
||||||
|
Loading…
Reference in New Issue
Block a user