AuthShield v0.0.1 AuthShield.Resources.Roles View Source

Roles are used to define an group of permissions that the user has. It usually works as an definition of the person function in the company.

We use this to implement and Role-based access control (RBAC).

RBAC is a policy-neutral access-control mechanism defined around roles and privileges.

The components of RBAC such as role-permissions and user-role relationships make it simple to perform user assignments.

This module implements an interface to deal with database transactions as inserts, updates, deletes, etc.

Link to this section Summary

Types

Transactional responses of failed

Transactional responses of success

Link to this section Types

Link to this type

failed_response()

View Source
failed_response() :: {:error, Ecto.Changeset.t()}

Transactional responses of failed

Link to this type

success_response()

View Source
success_response() :: {:ok, AuthShield.Resources.Schemas.Role.t()}

Transactional responses of success

Link to this section Functions

Link to this function

change_permissions(role, permissions)

View Source

Changes an set of AuthShield.Resources.Schemas.Permission of the AuthShield.Resources.Schemas.Role.

It will add or remove permissions from the list, so you should pass the all list every time you use this function.

Exemples:

  AuthShield.Resources.Roles.change_permissions(role, permissions)
Link to this function

change_permissions!(role, permissions)

View Source

Changes an set of AuthShield.Resources.Schemas.Permission of the AuthShield.Resources.Schemas.Role.

Similar to appeappend_permissionnd_role/2 but returns the struct or raises if the changeset is invalid.

Deletes a AuthShield.Resources.Schemas.Role register.

Exemples:

  AuthShield.Resources.Roles.delete(role)

Deletes a AuthShield.Resources.Schemas.Role register.

Similar to delete/1 but returns the struct or raises if the changeset is invalid.

Gets a AuthShield.Resources.Schemas.Role register by its filters.

Exemples:

  AuthShield.Resources.Roles.get_by(name: "admin")

Gets a Role register by its filters.

Similar to get_by/1 but returns the struct or raises if the changeset is invalid.

Creates a new AuthShield.Resources.Schemas.Role register.

Exemples:

  AuthShield.Resources.Roles.insert(%{
    name: "admin",
    description: "System administrator"
  })

Creates a new AuthShield.Resources.Schemas.Role register.

Similar to insert/1 but returns the struct or raises if the changeset is invalid.

Returns a list of AuthShield.Resources.Schemas.Role by its filters

Exemples:

  # Getting the all list
  AuthShield.Resources.Roles.list()

  # Filtering the list by field
  AuthShield.Resources.Roles.list(name: "admin")

Updates a AuthShield.Resources.Schemas.Role register.

Exemples:

  AuthShield.Resources.Roles.update(role, %{
    name: "sales",
    description: "The sales user roles"
  })

Updates a AuthShield.Resources.Schemas.Role register.

Similar to update/2 but returns the struct or raises if the changeset is invalid.