Skip to content

Commit

Permalink
Add example for switching organizations (#1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikprijck committed Jun 6, 2023
1 parent eb63035 commit 7ca5d97
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,25 @@ await client.loginWithPopup({
});
```

### Switch to a different organization

When working with multiple organizations, there might be a situation where you want your users to be able to switch between different organizations.

To do this, clear the local logged in state from your application and login to Auth0 again, leveraging any existing Auth0 session to prevent the user from being prompted for their credentials.

```ts
async function switchOrganization(newOrganization: string) {
await client.logout({ openUrl: false });
await client.loginWithRedirect({
authorizationParams: {
organization: newOrganization
}
});
}
```

**Note:** Ensure to pass any additional parameters to `loginWithRedirect` (or `loginWithPopup`) just as you might have passed on other occurences of calling login.

### Accept user invitations

Accept a user invitation through the SDK by creating a route within your application that can handle the user invitation URL, and log the user in by passing the `organization` and `invitation` parameters from this URL. You can either use `loginWithRedirect` or `loginWithPopup` as needed.
Expand Down

0 comments on commit 7ca5d97

Please sign in to comment.