Skip to main content

<AsgardeoOrganizationSwitcher />

You're reading Identity & Access Management 7.1.0. The newest release is 7.3.0, and Cloud has the newest features. Go to the newest release

<AsgardeoOrganizationSwitcher> lets the user switch between the organizations they belong to, using the WSO2 Identity Server Nuxt SDK (@asgardeo/nuxt).

Overview​

<AsgardeoOrganizationSwitcher> reads currentOrganization, myOrganizations, and switchOrganization() from useOrganization(). It shows the current organization and a menu of the user's organizations.

When the user picks an organization, the SDK calls POST /api/auth/organizations/switch. The server exchanges the session's token for a token scoped to that organization and reissues the session cookie.

After the switch, the SDK refreshes the organization data, the user profile and the authentication state on the page.

note

<AsgardeoOrganizationSwitcher> must render inside <AsgardeoRoot>. It needs preferences.user.fetchOrganizations to be true, which is the default.

Usage​

The component is auto-registered, so you don't need to import it.

Basic usage​

<template>
<AsgardeoSignedIn>
<AsgardeoOrganizationSwitcher />
</AsgardeoSignedIn>
</template>

Custom UI​

<template>
<AsgardeoOrganizationSwitcher>
<template #default="{ currentOrganization, organizations, handleSelect, isOpen, toggle }">
<button @click="toggle">{{ currentOrganization?.name ?? 'Select organization' }}</button>
<ul v-if="isOpen">
<li v-for="org in organizations" :key="org.id">
<button @click="handleSelect(org)">{{ org.name }}</button>
</li>
</ul>
</template>
</AsgardeoOrganizationSwitcher>
</template>

Props​

PropTypeDefaultDescription
classNamestring''CSS class for the root element.

Slots​

SlotSlot propsDescription
default{ currentOrganization, organizations, isLoading, isOpen, toggle, handleSelect }Replaces the built-in switcher. Call handleSelect(organization) to switch.

Was this page helpful?