From 05c4e2e0b487411d1ee46e89733635fa72f6376a Mon Sep 17 00:00:00 2001 From: Kang Ming Date: Mon, 28 Oct 2024 17:11:16 +0800 Subject: [PATCH] chore: only parse body if it's non-empty --- internal/api/admin.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/api/admin.go b/internal/api/admin.go index d2c45aa8f..63cde06a6 100644 --- a/internal/api/admin.go +++ b/internal/api/admin.go @@ -14,6 +14,7 @@ import ( "github.com/supabase/auth/internal/models" "github.com/supabase/auth/internal/observability" "github.com/supabase/auth/internal/storage" + "github.com/supabase/auth/internal/utilities" "golang.org/x/crypto/bcrypt" ) @@ -513,11 +514,10 @@ func (a *API) adminUserDelete(w http.ResponseWriter, r *http.Request) error { // ShouldSoftDelete defaults to false params := &adminUserDeleteParams{} - if err := retrieveRequestParams(r, params); err != nil { - if err.(*HTTPError).ErrorCode == ErrorCodeBadJSON { - // request body is empty so the default behavior should be to hard delete the user - params.ShouldSoftDelete = false - } else { + if body, _ := utilities.GetBodyBytes(r); len(body) != 0 { + // we only want to parse the body if it's not empty + // retrieveRequestParams will handle any errors with stream + if err := retrieveRequestParams(r, params); err != nil { return err } }