fix: concurrency
This commit is contained in:
@@ -3,7 +3,6 @@ package middleware
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -44,7 +43,7 @@ func TokenIsNotExpired(access_token string) bool {
|
||||
func GetUserProfile(context *gin.Context) {
|
||||
|
||||
session := sessions.Default(context)
|
||||
access_token := session.Get("access_token")
|
||||
/* access_token := session.Get("access_token")
|
||||
user_profile_client := http.Client{}
|
||||
|
||||
user_profile_url, err := url.Parse("https://" + os.Getenv("AUTH0_DOMAIN") + os.Getenv("AUTH0_USER_INFO_ENDPOINT"))
|
||||
@@ -71,10 +70,15 @@ func GetUserProfile(context *gin.Context) {
|
||||
}
|
||||
|
||||
defer user_profile_response.Body.Close()
|
||||
user_profile_bytes, _ := io.ReadAll(user_profile_response.Body)
|
||||
|
||||
user_profile_bytes, _ := io.ReadAll(user_profile_response.Body) */
|
||||
var user_profile dto.UserProfileResponse
|
||||
json.Unmarshal(user_profile_bytes, &user_profile)
|
||||
profile_session := session.Get("profile").(map[string]interface{})
|
||||
user_profile.Sub = profile_session["sub"].(string)
|
||||
user_profile.Email = profile_session["email"].(string)
|
||||
user_profile.Verified = profile_session["email_verified"].(bool)
|
||||
user_profile.PictureUrl = profile_session["picture"].(string)
|
||||
user_profile.Nickname = profile_session["nickname"].(string)
|
||||
user_profile.Updated_at = profile_session["updated_at"].(string)
|
||||
context.Set("user_profile", user_profile)
|
||||
context.Next()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user