aboutsummaryrefslogtreecommitdiff
path: root/backend/internal/ibd/userinfo.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/internal/ibd/userinfo.go')
-rw-r--r--backend/internal/ibd/userinfo.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/backend/internal/ibd/userinfo.go b/backend/internal/ibd/userinfo.go
index ba7a5b5..ed61497 100644
--- a/backend/internal/ibd/userinfo.go
+++ b/backend/internal/ibd/userinfo.go
@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
+ "io"
"log/slog"
"net/http"
)
@@ -24,17 +25,25 @@ func (c *Client) UserInfo(ctx context.Context, cookie *http.Cookie) (*UserProfil
if err != nil {
return nil, err
}
+ defer func(Body io.ReadCloser) {
+ _ = Body.Close()
+ }(resp.Body)
- if resp.Result.StatusCode != http.StatusOK {
+ content, err := io.ReadAll(resp.Body)
+ if err != nil {
+ return nil, fmt.Errorf("failed to read response body: %w", err)
+ }
+
+ if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf(
"unexpected status code %d: %s",
- resp.Result.StatusCode,
- resp.Result.Content,
+ resp.StatusCode,
+ string(content),
)
}
up := new(UserProfile)
- if err = up.UnmarshalJSON([]byte(resp.Result.Content)); err != nil {
+ if err = up.UnmarshalJSON(content); err != nil {
return nil, err
}