View Source Glific.AccessControl.UserRole (Glific v5.1.6)

A pipe for managing the user roles

Link to this section Summary

Functions

Standard changeset pattern we use for all data types

Creates a access control.

Update user roles based on add_role_ids and delete_role_ids and return number_deleted as integer and roles added as access_controls

Link to this section Types

@type t() :: %Glific.AccessControl.UserRole{
  __meta__: Ecto.Schema.Metadata.t(),
  id: non_neg_integer() | nil,
  organization:
    Glific.Partners.Organization.t() | Ecto.Association.NotLoaded.t() | nil,
  organization_id: non_neg_integer() | nil,
  role: Glific.AccessControl.Role.t() | Ecto.Association.NotLoaded.t() | nil,
  role_id: term(),
  user: Glific.Users.User.t() | Ecto.Association.NotLoaded.t() | nil,
  user_id: term()
}

Link to this section Functions

@spec changeset(t(), map()) :: Ecto.Changeset.t()

Standard changeset pattern we use for all data types

Link to this function

create_user_role(attrs \\ %{})

View Source
@spec create_user_role(map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}

Creates a access control.

examples

Examples

iex> create_user_role(%{field: value})
{:ok, %UserRole{}}
iex> create_user_role(%{field: bad_value})
{:error, %Ecto.Changeset{}}
Link to this function

delete_user_roles_by_role_ids(user_id, role_ids)

View Source
@spec delete_user_roles_by_role_ids(integer(), list()) :: {integer(), nil | [term()]}

Delete user roles

Link to this function

update_user_roles(attrs)

View Source
@spec update_user_roles(map()) :: map()

Update user roles based on add_role_ids and delete_role_ids and return number_deleted as integer and roles added as access_controls