Join an Organization Component - PropelAuth Docs

Join an Organization Component

PropelAuth's Join an Organization component can be used in tandem with the Create Organization component when your user has a Login State of USER_MUST_BE_IN_AT_LEAST_ONE_ORG. If their email domain matches the domain of an organization that is joinable, that organization will be available for the user to join.

We highly recommend reviewing the Login and Signup Guide if using any of our login or signup components.

Join an Organization

Select the organization you'd like to join. Based on your email address, you can join any of the orgs in the dropdown below.

Join Organization


Shadcn Installation

Install this component from our shadcn registry.

npx shadcn@latest add https://components.propelauth.com/r/join-an-organization.json

Reference APIs

These are the APIs that are used by the above component. You can use these APIs directly in your own code.

fetchJoinableOrgs

Returns an array of organizations that the user can join based on their email domain.

Success Response

Response Functions

The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.

Request

const { fetchJoinableOrgs } = useAuthFrontendApis()

const response = await fetchJoinableOrgs()
response.handle({
    success(data) {
        console.log(data.orgs)
    },
    orgsNotEnabled(error) {
        console.error('Organizations are disabled', error)
    },
    unexpectedOrUnhandled(error) {
        console.error('Unexpected or unhandled', error.user_facing_error)
    },
})

Successful Response

{
    "orgs": [
        {
            "id": "org_123",
            "name": "Acme Corp"
        },
        {
            "id": "org_456",
            "name": "Widget Co"
        }
    ]
}

joinOrg

Adds the logged in user as a member of the provided organization.

Arguments

Success Response

Response Functions

The response object has a handle function that you can use to handle the response. These functions can be async, and you can return values from them.

Request

const { joinOrg } = useAuthFrontendApis()

const response = await joinOrg("1189c444-8a2d-4c41-8b4b-ae43ce79a492")
response.handle({
    success(data) {
        console.log("User added to org: ", data.org_id)
    },
    orgNotFound(error) {
        console.error('Org not found', error)
    },
    orgsNotEnabled(error) {
        console.error('Org not enabled', error)
    },
    userAlreadyInTooManyOrgs(error) {
        console.error('User already in too many orgs', error)
    },
    orgMaxUsersLimitExceeded(error) {
        console.error('Org max users limit exceeded', error)
    },
    unexpectedOrUnhandled(error) {
        console.error('Unexpected or unhandled error', error)
    },
})

Successful Response

{
    "org_id": "1189c444-8a2d-4c41-8b4b-ae43ce79a492",
    "first_org": true
}