defmodule Dialup.Auth.Accounts do @moduledoc """ 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`. """ @type user :: map() | struct() @callback get_user_by_session_token(token :: binary()) :: user() | nil @callback generate_user_session_token(user()) :: binary() @callback delete_session_token(token :: binary()) :: :ok @callback get_user_by_email_and_password(email :: binary(), password :: binary()) :: {:ok, user()} | {:error, :invalid_credentials} @callback register_user(attrs :: map()) :: {:ok, user()} | {:error, term()} @callback get_user_by_email(email :: binary()) :: user() | nil @callback deliver_user_reset_password_instructions(user(), reset_url_fun :: function()) :: :ok @callback reset_user_password(user(), attrs :: map()) :: {:ok, user()} | {:error, term()} @callback get_user_by_reset_password_token(token :: binary()) :: user() | nil @optional_callbacks [ register_user: 1, get_user_by_email: 1, deliver_user_reset_password_instructions: 2, reset_user_password: 2, get_user_by_reset_password_token: 1 ] end