Dialup.Auth.Accounts behaviour (Dialup v0.2.0)

Copy Markdown View Source

Behaviour implemented by generated Accounts contexts.

Dialup.Auth resolves the current user through this callback module configured on Dialup.Auth.Plug or use Dialup, auth_accounts: MyApp.Accounts.

Summary

Types

user()

@type user() :: map() | struct()

Callbacks

delete_session_token(token)

@callback delete_session_token(token :: binary()) :: :ok

deliver_user_reset_password_instructions(user, reset_url_fun)

(optional)
@callback deliver_user_reset_password_instructions(user(), reset_url_fun :: function()) ::
  :ok

generate_user_session_token(user)

@callback generate_user_session_token(user()) :: binary()

get_user_by_email(email)

(optional)
@callback get_user_by_email(email :: binary()) :: user() | nil

get_user_by_email_and_password(email, password)

@callback get_user_by_email_and_password(email :: binary(), password :: binary()) ::
  {:ok, user()} | {:error, :invalid_credentials}

get_user_by_reset_password_token(token)

(optional)
@callback get_user_by_reset_password_token(token :: binary()) :: user() | nil

get_user_by_session_token(token)

@callback get_user_by_session_token(token :: binary()) :: user() | nil

register_user(attrs)

(optional)
@callback register_user(attrs :: map()) :: {:ok, user()} | {:error, term()}

reset_user_password(user, attrs)

(optional)
@callback reset_user_password(user(), attrs :: map()) :: {:ok, user()} | {:error, term()}