This commit is contained in:
Jeffrey Duroyon
2020-07-19 02:05:40 +02:00
parent f6e0a826a1
commit 90f86a02f4
3 changed files with 365 additions and 33 deletions

View File

@@ -14,8 +14,6 @@ import (
"google.golang.org/api/oauth2/v2"
)
var httpClient = &http.Client{}
func (hc *handlersContext) getAllUsers(c *gin.Context) {
users, err := hc.db.GetAllUsers()
if err != nil {
@@ -34,7 +32,12 @@ func (hc *handlersContext) connectUser(c *gin.Context) {
return
}
oauth2Service, err := oauth2.New(httpClient)
oauth2Service, err := oauth2.New(&http.Client{})
if oauth2Service == nil {
fmt.Println(err)
utils.JSONError(c.Writer, model.ErrInternalServer)
return
}
tokenInfoCall := oauth2Service.Tokeninfo()
tokenInfoCall.IdToken(authorizationHeaderSplitted[1])
tokenInfo, err := tokenInfoCall.Do()
@@ -63,7 +66,8 @@ func (hc *handlersContext) connectUser(c *gin.Context) {
utils.JSONError(c.Writer, model.ErrInternalServer)
return
}
fmt.Println("Found the user " + user.Nickname)
fmt.Println("Return 200")
utils.JSON(c.Writer, 200, user)
}
func (hc *handlersContext) createUser(c *gin.Context) {