added logging

This commit is contained in:
2026-01-05 16:03:53 +08:00
parent 81d3c5a3bd
commit 744796a4b1
+11 -2
View File
@@ -129,11 +129,20 @@ func checkUserAuthorization(userID, accessToken string) (bool, string, error) {
}
defer resp.Body.Close()
// Read the response body first for logging
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
helper.LogError(err, "Failed to read authorization response body")
return false, "", err
}
log.Printf("AUTHZ RAW RESPONSE Status: %d, Body: %s", resp.StatusCode, string(bodyBytes))
// Parse response
var authResp models.AuthorizationResponse
if err := json.NewDecoder(resp.Body).Decode(&authResp); err != nil {
if err := json.Unmarshal(bodyBytes, &authResp); err != nil {
helper.LogError(err, "Failed to decode authorization response")
log.Printf("Failed to unmarshal response body: %s", string(bodyBytes))
return false, "", err
}