Skip to content

Commit 8dc3935

Browse files
committed
fixes a bug
1 parent 82d8ac6 commit 8dc3935

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

supertokens/supertokens.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,19 @@ func (s *superTokens) middleware(theirHandler http.Handler) http.Handler {
243243

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

246-
var tenantId, err = GetTenantIdFuncFromUsingMultitenancyRecipe(*finalTenantId, userContext)
247-
if err != nil {
248-
err = s.errorHandler(err, r, dw, userContext)
249-
if err != nil && !dw.IsDone() {
250-
s.OnSuperTokensAPIError(err, r, dw)
246+
tenantId := "public"
247+
248+
if GetTenantIdFuncFromUsingMultitenancyRecipe != nil {
249+
// this can be nil if the user has not used the multitenancy recipe
250+
// which happens if they are only using the session recipe.
251+
tenantId, err = GetTenantIdFuncFromUsingMultitenancyRecipe(*finalTenantId, userContext)
252+
if err != nil {
253+
err = s.errorHandler(err, r, dw, userContext)
254+
if err != nil && !dw.IsDone() {
255+
s.OnSuperTokensAPIError(err, r, dw)
256+
}
257+
return
251258
}
252-
return
253259
}
254260

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

0 commit comments

Comments
 (0)