Skip to content

Commit

Permalink
fixes a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed May 27, 2024
1 parent 82d8ac6 commit 8dc3935
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions supertokens/supertokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,19 @@ func (s *superTokens) middleware(theirHandler http.Handler) http.Handler {

LogDebugMessage("middleware: Request being handled by recipe. ID is: " + *id)

var tenantId, err = GetTenantIdFuncFromUsingMultitenancyRecipe(*finalTenantId, userContext)
if err != nil {
err = s.errorHandler(err, r, dw, userContext)
if err != nil && !dw.IsDone() {
s.OnSuperTokensAPIError(err, r, dw)
tenantId := "public"

if GetTenantIdFuncFromUsingMultitenancyRecipe != nil {
// this can be nil if the user has not used the multitenancy recipe
// which happens if they are only using the session recipe.
tenantId, err = GetTenantIdFuncFromUsingMultitenancyRecipe(*finalTenantId, userContext)
if err != nil {
err = s.errorHandler(err, r, dw, userContext)
if err != nil && !dw.IsDone() {
s.OnSuperTokensAPIError(err, r, dw)
}
return
}
return
}

apiErr := finalMatchedRecipe.HandleAPIRequest(*id, tenantId, r, dw, theirHandler.ServeHTTP, path, method, userContext)
Expand Down

0 comments on commit 8dc3935

Please sign in to comment.