Description

Service for creating and managing organization users

Constructors

Methods

  • Delete a user from an organization

    Parameters

    • orgId: string

      organization id

    • userId: string

      user id

    Returns Promise<boolean>

    true if the operation is successful

  • Read all users of an organization. As this data is not in a seprate collection, we need to read the organization and get the users from it.

    Parameters

    • orgId: string

      organization id

    Returns Promise<{
        id: string;
        role: "owner" | "admin" | "member" | "guest";
    }[]>

    all users of the organization

  • Get a user's role in an organization

    Parameters

    • orgId: string

      organization id

    • userId: string

      user id

    Returns Promise<undefined | string>

    user's role in the organization, or undefined if not found

  • Test if user is an admin of an organization

    Parameters

    • orgId: string

      organization id

    • userId: string

      user id

    Returns Promise<boolean>

    true if user has the admin role in the organization

  • Test if user is a guest of an organization

    Parameters

    • orgId: string

      organization id

    • userId: string

      user id

    Returns Promise<boolean>

    true if user has the guest role in the organization

  • Test if user is the last owner of an organization

    Parameters

    • orgId: string

      organization id

    • userId: string

      user id

    Returns Promise<boolean>

    true if the organization only has one owner, and it is the user

  • Test if user is a member of an organization

    Parameters

    • orgId: string

      organization id

    • userId: string

      user id

    Returns Promise<boolean>

    true if user has the member role in the organization

  • Test if user is the owner of an organization

    Parameters

    • orgId: string

      organization id

    • userId: string

      user id

    Returns Promise<boolean>

    true if user has the owner role in the organization

  • Test if user belongs to an organization

    Parameters

    • orgId: string

      organization id

    • userId: string

      user id

    Returns Promise<boolean>

    true if user belongs to the organization

  • List all users of an organization with a mock pagination. This is a mock pagination as the data is not stored in a separate collection, and the API is not truly paginated nor supports filtering.

    Parameters

    • orgId: string

      organization id

    • offset: number

      offset for pagination

    • limit: number

      limit for pagination

    Returns Promise<{
        count: number;
        result: OrganizationUser[];
        total: number;
    }>

    all users of the organization

  • Insert or update organization users for an organization. If the user already exists, the role will be updated.

    Parameters

    • orgId: string

      organization id

    • users: OrganizationUser[]

      users to be added or updated

    Returns Promise<boolean>

    true if the operation is successful

Properties

db: Db
logger: null | Logger
orgRepository: MongoRepository<OrganizationEntity>
userAPI: UserDefaultAdapterAPI
COLLECTION_ORGANIZATION: "organizations" = 'organizations'

Generated using TypeDoc