View Source Plausible.Site.Memberships.CreateInvitation (Plausible v0.0.1)

Service for inviting new or existing users to a sites, including ownershhip transfers.

Summary

Functions

Invites a new team member to the given site. Returns a %Plausible.Auth.Invitation{} struct and sends the invitee an email to accept this invitation.

Types

@type invite_error() ::
  Ecto.Changeset.t()
  | :already_a_member
  | :transfer_to_self
  | :no_plan
  | {:over_limit, non_neg_integer()}
  | :forbidden

Functions

Link to this function

bulk_create_invitation(sites, inviter, invitee_email, role, opts \\ [])

View Source
@spec bulk_create_invitation(
  [Plausible.Site.t()],
  Plausible.Auth.User.t(),
  String.t(),
  atom(),
  Keyword.t()
) :: {:ok, [Plausible.Auth.Invitation.t()]} | {:error, invite_error()}
Link to this function

bulk_transfer_ownership_direct(sites, new_owner)

View Source
@spec bulk_transfer_ownership_direct([Plausible.Site.t()], Plausible.Auth.User.t()) ::
  {:ok, [Plausible.Site.Membership.t()]}
  | {:error, invite_error() | Plausible.Billing.Quota.over_limits_error()}
Link to this function

create_invitation(site, inviter, invitee_email, role)

View Source
@spec create_invitation(
  Plausible.Site.t(),
  Plausible.Auth.User.t(),
  String.t(),
  atom()
) ::
  {:ok, Plausible.Auth.Invitation.t()} | {:error, invite_error()}

Invites a new team member to the given site. Returns a %Plausible.Auth.Invitation{} struct and sends the invitee an email to accept this invitation.

The inviter must have enough permissions to invite the new team member, otherwise this function returns {:error, :forbidden}.

If the new team member role is :owner, this function handles the invitation as an ownership transfer and requires the inviter to be the owner of the site.