Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add isTenantIdDefined #93

Open
wants to merge 1 commit into
base: 0.7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### Changes

- Added `isTenantIdDefined` to multitenancy

## [0.7.1] - 2023-07-24

### Changes
Expand Down
2 changes: 1 addition & 1 deletion bundle/multitenancy.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions lib/build/recipe/multitenancy/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

159 changes: 158 additions & 1 deletion lib/build/recipe/multitenancy/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions lib/ts/recipe/multitenancy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,28 @@ export default class RecipeWrapper {
userContext: getNormalisedUserContext(input?.userContext),
});
}

static async isTenantIdDefined(input?: { userContext?: any }): Promise<boolean> {
return (
(await Recipe.getInstanceOrThrow().recipeImplementation.getTenantId({
userContext: getNormalisedUserContext(input?.userContext),
})) !== undefined
);
}

static AllowedDomainsClaim = AllowedDomainsClaim;
}

const init = RecipeWrapper.init;
const getLoginMethods = RecipeWrapper.getLoginMethods;
const getTenantId = RecipeWrapper.getTenantId;
const isTenantIdDefined = RecipeWrapper.isTenantIdDefined;

export {
init,
getLoginMethods,
getTenantId,
isTenantIdDefined,
RecipeInterface,
PreAPIHookContext,
PostAPIHookContext,
Expand Down
7 changes: 7 additions & 0 deletions test/with-typescript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import {
import {
RecipeInterface as MultitenancyRecipeInterface,
PreAndPostAPIHookAction as MultitenancyAction,
isTenantIdDefined,
} from "../../recipe/multitenancy";
import ThirdPartyPasswordless from "../../recipe/thirdpartypasswordless";
import { RecipeInterface as SessionRecipeInterface, UserInput as SessionUserInput } from "../../recipe/session/types";
Expand Down Expand Up @@ -2008,3 +2009,9 @@ function reexportedHandlers() {
CookieHandlerReference.getReferenceOrThrow();
WindowHandlerReference.getReferenceOrThrow();
}

Multitenancy.isTenantIdDefined();
isTenantIdDefined();

Multitenancy.isTenantIdDefined({ userContext: {} });
isTenantIdDefined({ userContext: {} });