Skip to content

Commit

Permalink
fix: set an empty json body if no body is set (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddyDevelop authored Nov 27, 2024
1 parent 9afe292 commit 61a44fe
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions server/api/handler/webauthn.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
auditlog "github.com/teamhanko/passkey-server/audit_log"
"github.com/teamhanko/passkey-server/persistence"
"github.com/teamhanko/passkey-server/persistence/models"
"io"
"net/http"
"strings"
)

type WebauthnHandler interface {
Expand Down Expand Up @@ -49,6 +51,11 @@ func (w *webauthnHandler) handleError(logger auditlog.Logger, logType models.Aud

func BindAndValidateRequest[I request.CredentialRequests | request.WebauthnRequests](ctx echo.Context) (*I, error) {
var requestDto I

if ctx.Request().ContentLength <= 0 {
ctx.Request().Body = io.NopCloser(strings.NewReader("{}"))
}

err := ctx.Bind(&requestDto)
if err != nil {
ctx.Logger().Error(err)
Expand Down

0 comments on commit 61a44fe

Please sign in to comment.