Skip to content

Commit

Permalink
fix(api): multiple userID binding on user create token
Browse files Browse the repository at this point in the history
The `CreateUserToken` handler will now accept the user ID either in the
parameters or the header, with preference given to the header when both
are provided.
  • Loading branch information
heiytor authored and henrybarreto committed Aug 26, 2024
1 parent ef343eb commit be042c3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions api/routes/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,6 @@ func (h *Handler) CreateUserToken(c gateway.Context) error {
return err
}

// If the tenant id is not in the parameters, we get it from the header.
if req.TenantID == "" {
req.TenantID = c.Request().Header.Get("X-Tenant-ID")
}

if err := c.Validate(req); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/requests/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ type AuthTokenSwap struct {
}

type CreateUserToken struct {
UserID string `header:"X-ID" validate:"required"`
UserID string `param:"id" header:"X-ID" validate:"required"`
TenantID string `param:"tenant" validate:"omitempty,uuid"`
}

0 comments on commit be042c3

Please sign in to comment.