Switch Logged In User Organization Using an Organization Picker
Last Updated:
Overview
This article describes how to implement a mechanism that allows logged-in users to switch their current organization context. This functionality requires the New Universal Login experience, as Auth0 Organizations are not supported in Classic Universal Login.
Applies To
-
Auth0 Organizations
-
New Universal Login
-
Auth0 Single Page App SDK
Solution
-
Ensure the tenant is configured to use the New Universal Login experience.
-
Provide a mechanism in the application user interface, such as a dropdown menu or button, for the user to select the target organization.
-
Call the
loginWithRedirect()method from the Auth0 SDK upon selection. -
Pass the chosen organization's ID in the
organizationparameter:
loginWithRedirect({ organization: 'NEW_ORG_ID' })
This process redirects the user, establishes the session within the context of the newly selected organization, and returns the user to the application with the appropriate tokens.