Skip to content

Commit

Permalink
removes onHandleEvent listener for sign out in multi tenancy to clear…
Browse files Browse the repository at this point in the history
… saved tenant id
  • Loading branch information
rishabhpoddar committed Jul 11, 2024
1 parent 2a3d6ef commit 18d9b15
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,32 +233,6 @@ We want to render the `AuthPage` component to show on `^{form_websiteBasePath}/*
The `AuthPage` will replace the call to `getSuperTokensRoutesForReactRouterDom` or `getRoutingComponent` that you may have added to your app from the quick setup section.
:::

Finally, we need to clear the saved tenantId from localstorage in the following events:
- When the user signs out: Since the user can get to choose the tenant ID again when they sign in.
- When the session has been revoked / expired and the frontend detects this: This will redirect the user to the login screen, where they can choose the tenant ID again.
- When the user signs in: Since now the user's session will be the source of their tenant ID.

<FrontendPreBuiltUITabs>

<TabItem value="reactjs">

```tsx
import Session from "supertokens-auth-react/recipe/session";

Session.init({
// other configs..
onHandleEvent: (event) => {
if (["SIGN_OUT", "UNAUTHORISED", "SESSION_CREATED"].includes(event.action)) {
window.localStorage.removeItem("tenantId");
}
},
})
```

</TabItem>

</FrontendPreBuiltUITabs>

</AppInfoForm>

<!-- END COPY SECTION -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,32 +233,6 @@ We want to render the `AuthPage` component to show on `^{form_websiteBasePath}/*
The `AuthPage` will replace the call to `getSuperTokensRoutesForReactRouterDom` or `getRoutingComponent` that you may have added to your app from the quick setup section.
:::

Finally, we need to clear the saved tenantId from localstorage in the following events:
- When the user signs out: Since the user can get to choose the tenant ID again when they sign in.
- When the session has been revoked / expired and the frontend detects this: This will redirect the user to the login screen, where they can choose the tenant ID again.
- When the user signs in: Since now the user's session will be the source of their tenant ID.

<FrontendPreBuiltUITabs>

<TabItem value="reactjs">

```tsx
import Session from "supertokens-auth-react/recipe/session";

Session.init({
// other configs..
onHandleEvent: (event) => {
if (["SIGN_OUT", "UNAUTHORISED", "SESSION_CREATED"].includes(event.action)) {
window.localStorage.removeItem("tenantId");
}
},
})
```

</TabItem>

</FrontendPreBuiltUITabs>

</AppInfoForm>

<!-- END COPY SECTION -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,32 +233,6 @@ We want to render the `AuthPage` component to show on `^{form_websiteBasePath}/*
The `AuthPage` will replace the call to `getSuperTokensRoutesForReactRouterDom` or `getRoutingComponent` that you may have added to your app from the quick setup section.
:::

Finally, we need to clear the saved tenantId from localstorage in the following events:
- When the user signs out: Since the user can get to choose the tenant ID again when they sign in.
- When the session has been revoked / expired and the frontend detects this: This will redirect the user to the login screen, where they can choose the tenant ID again.
- When the user signs in: Since now the user's session will be the source of their tenant ID.

<FrontendPreBuiltUITabs>

<TabItem value="reactjs">

```tsx
import Session from "supertokens-auth-react/recipe/session";

Session.init({
// other configs..
onHandleEvent: (event) => {
if (["SIGN_OUT", "UNAUTHORISED", "SESSION_CREATED"].includes(event.action)) {
window.localStorage.removeItem("tenantId");
}
},
})
```

</TabItem>

</FrontendPreBuiltUITabs>

</AppInfoForm>

<!-- END COPY SECTION -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,32 +233,6 @@ We want to render the `AuthPage` component to show on `^{form_websiteBasePath}/*
The `AuthPage` will replace the call to `getSuperTokensRoutesForReactRouterDom` or `getRoutingComponent` that you may have added to your app from the quick setup section.
:::

Finally, we need to clear the saved tenantId from localstorage in the following events:
- When the user signs out: Since the user can get to choose the tenant ID again when they sign in.
- When the session has been revoked / expired and the frontend detects this: This will redirect the user to the login screen, where they can choose the tenant ID again.
- When the user signs in: Since now the user's session will be the source of their tenant ID.

<FrontendPreBuiltUITabs>

<TabItem value="reactjs">

```tsx
import Session from "supertokens-auth-react/recipe/session";

Session.init({
// other configs..
onHandleEvent: (event) => {
if (["SIGN_OUT", "UNAUTHORISED", "SESSION_CREATED"].includes(event.action)) {
window.localStorage.removeItem("tenantId");
}
},
})
```

</TabItem>

</FrontendPreBuiltUITabs>

</AppInfoForm>

<!-- END COPY SECTION -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,32 +233,6 @@ We want to render the `AuthPage` component to show on `^{form_websiteBasePath}/*
The `AuthPage` will replace the call to `getSuperTokensRoutesForReactRouterDom` or `getRoutingComponent` that you may have added to your app from the quick setup section.
:::

Finally, we need to clear the saved tenantId from localstorage in the following events:
- When the user signs out: Since the user can get to choose the tenant ID again when they sign in.
- When the session has been revoked / expired and the frontend detects this: This will redirect the user to the login screen, where they can choose the tenant ID again.
- When the user signs in: Since now the user's session will be the source of their tenant ID.

<FrontendPreBuiltUITabs>

<TabItem value="reactjs">

```tsx
import Session from "supertokens-auth-react/recipe/session";

Session.init({
// other configs..
onHandleEvent: (event) => {
if (["SIGN_OUT", "UNAUTHORISED", "SESSION_CREATED"].includes(event.action)) {
window.localStorage.removeItem("tenantId");
}
},
})
```

</TabItem>

</FrontendPreBuiltUITabs>

</AppInfoForm>

<!-- END COPY SECTION -->
Expand Down

0 comments on commit 18d9b15

Please sign in to comment.