Skip to content

Commit

Permalink
chore: only parse body if it's non-empty
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay committed Oct 28, 2024
1 parent 834d03c commit 05c4e2e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/api/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit 05c4e2e

Please sign in to comment.