InfoThis documentation is just for PropelAuth Components, an optional library for those who want deeper design control over their UIs.Click here to view our standard documentation

Invite User to Organization Component

PropelAuth's Invite User to Organization component allows you to customize the flow around a user inviting another user to their organization in your app.

Invite User to Organization


Reference APIs

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

inviteUserToOrg

Sends an invitation to a user to join an organization.

Arguments

  • Name
    org_id *
    Type
    string
    Description
    The ID of the org.
  • Name
    email *
    Type
    string
    Description
    The email of the user who is being invited.
  • Name
    role *
    Type
    string
    Description
    The role the user will have.
  • Name
    additional_roles
    Type
    string[]
    Description
    If using multiple roles per user, an array of additional roles for the user.

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.

  • Name
    success
    Description
    Successful request.
  • Name
    noInvitePermission
    Description
    The user does not have permission to invite other users to the organization.
  • Name
    orgNotFound
    Description
    The org ID cannot be found.
  • Name
    orgsNotEnabled
    Description
    Organizations are not enabled for the project.
  • Name
    userAlreadyInOrg
    Description
    The email provided is already a member of the organization.
  • Name
    orgMaxUsersLimitExceeded
    Description
    The org's user limit has already been met.
  • Name
    badRequest
    Description
    Incorrect arguments given.
  • Name
    unauthorized
    Description
    The user is not logged in.
  • Name
    unexpectedOrUnhandled
    Description
    An unexpected error occurred.

Request

const { inviteUserToOrg } = useAuthFrontendApis()

const response = await inviteUserToOrg({
    org_id: '1189c444-8a2d-4c41-8b4b-ae43ce79a492',
    email: 'test@example.com',
    role: 'Admin',
    // if using multi-role support
    additional_roles: [
        "Member"
    ]
})
response.handle({
    success: () => {
        console.log('User invited')
    },
    badRequest(error) {
        for (const [field, fieldErrorMessage] of Object.entries(error.user_facing_errors)) {
            console.log('Error: "' + fieldErrorMessage + '" for field: "' + field + '"')
        }
    },
    noInvitePermission(error) {
        console.error('No invite permission', error)
    },
    orgNotFound(error) {
        console.error('Org not found', error)
    },
    orgsNotEnabled(error) {
        console.error('Org not enabled', error)
    },
    userAlreadyInOrg(error) {
        console.error('User already in org', error)
    },
    orgMaxUsersLimitExceeded(error) {
        console.error('Org max users limit exceeded', error)
    },
    unexpectedOrUnhandled(error) {
        console.error('Unexpected or unhandled error', error)
    },
})

Successful Response

{}