Skip to content

Commit

Permalink
change ioutil to io (ioutil is deprecated)
Browse files Browse the repository at this point in the history
  • Loading branch information
consolethinks committed Aug 16, 2024
1 parent 273916f commit 905ecfc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions datasetUtils/authenticateUser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package datasetUtils
import (
"bytes"
"encoding/json"
"io/ioutil"
"io"
"log"
"net/http"
"strings"
Expand All @@ -26,6 +26,9 @@ func AuthenticateUser(client *http.Client, APIServer string, username string, pa
// try functional accounts first

req, err := http.NewRequest("POST", APIServer+"/Users/login", bytes.NewBuffer(cred))
if err != nil {
log.Fatal(err)
}
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
Expand Down Expand Up @@ -59,6 +62,9 @@ func AuthenticateUser(client *http.Client, APIServer string, username string, pa
} else {
// then try normal user account
req, err = http.NewRequest("POST", strings.Replace(APIServer, "api/v3", "auth/msad", 1), bytes.NewBuffer(cred))
if err != nil {
log.Fatal(err)
}
req.Header.Set("Content-Type", "application/json")
resp, err = client.Do(req)
if err != nil {
Expand All @@ -81,8 +87,11 @@ func AuthenticateUser(client *http.Client, APIServer string, username string, pa
// now get email from UserIdentity collections
var myurl = APIServer + "/UserIdentities?filter=%7B%22where%22%3A%7B%22userId%22%3A%22" + auth2.UserId + "%22%7D%7D&access_token=" + auth2.Access_token
resp, err := client.Get(myurl)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)
//fmt.Printf("Result:%s",string(body))
type NormalUser struct {
Profile struct {
Expand Down

0 comments on commit 905ecfc

Please sign in to comment.