func verifyUser(w http.ResponseWriter, r *http.Request) {
supabaseClient := supabase.SupabaseClient
var body map[string]string
err := json.NewDecoder(r.Body).Decode(&body)
if err != nil || body == nil {
fmt.Println(err)
w.WriteHeader(http.StatusBadRequest)
responseUtils.WriteResponse(w, http.StatusBadRequest, "JSON Body contains invalid parameters", nil)
return
}
decoded := helper.Decode(body["accessToken"])
insertResponse, count, err := supabaseClient.From("users").Insert(helper.User{
Email: decoded.Email,
Provider: decoded.AppMetadata.Provider,
LoggedIn: true,
SessionID: decoded.SessionID,
ImgURL: decoded.UserMetadata.AvatarURL,
FullName: decoded.UserMetadata.FullName,
}, false, "", "", "").Single().Execute()
fmt.Println(insertResponse, count, err)
responseUtils.WriteResponse(w, http.StatusOK, "User verified successfully!", insertResponse)
return
}
} else {
data, count, err := supabaseClient.From("users").Update(helper.SessionUpdate{
SessionId: decoded.SessionID,
LoggedIn: true,
}, "minimal", "exact").Eq("email", decoded.Email).Eq("provider", decoded.AppMetadata.Provider).Execute();
if err != nil {
fmt.Println(err)
w.WriteHeader(http.StatusInternalServerError)
responseUtils.WriteResponse(w, http.StatusInternalServerError, "Something went wrong when updating user", nil)
return
}
fmt.Println(data, count);
}
}
I was expecting the record to be inserted into the table but facing the following print response. Since there is much less documentation on the supabase-go repo
here’s the link for reference
https://github.com/supabase-community/supabase-go
[] 0 (22007) invalid input syntax for type timestamp with time zone: ""