authority v0.1.0 Authority.Registration behaviour

A behaviour for registering and updating users.

Usage

defmodule MyApp.Accounts.Registration do
  use Authority.Registration

  @impl Authority.Registration
  def create_user(params) do
    # Create a user
  end

  @impl Authority.Registration
  def get_user(id) do
    # Get a user by ID
  end

  @impl Authority.Registration
  def update_user(user, params) do
    # Update the user
  end

  @impl Authority.Registration
  def delete_user(user) do
    # Delete the user
  end
end

Link to this section Summary

Types

An error returned from creating/updating/deleting a user

Parameters needed to create a user. For example,

A user. Can be any type that represents a user for your application

Callbacks

Creates a user

Deletes a user

Gets a user by ID

Updates a user

Link to this section Types

Link to this type error()
error() :: {:error, term()}

An error returned from creating/updating/deleting a user.

Link to this type params()
params() :: map()

Parameters needed to create a user. For example,

%{
  email: "my@email.com",
  password: "password",
  password_confirmation: "password"
}
Link to this type user()
user() :: any()

A user. Can be any type that represents a user for your application.

Link to this section Callbacks

Link to this callback create_user(params)
create_user(params()) :: {:ok, user()} | error()

Creates a user.

Link to this callback delete_user(user)
delete_user(user()) :: {:ok, user()} | error()

Deletes a user.

Link to this callback get_user(integer)
get_user(integer()) :: {:ok, user()} | error()

Gets a user by ID.

Link to this callback update_user(user, params)
update_user(user(), params()) :: {:ok, term()} | error()

Updates a user.