Pow v0.1.0-alpha.1 Pow.Ecto.Schema behaviour View Source

Handles the Ecto schema for user.

Usage

Configure lib/my_project/users/user.ex the following way:

defmodule MyApp.Users.User do
  use Ecto.Schema
  use Pow.Ecto.Schema,
    user_id_field: :email,
    password_hash_methods: {&Pow.Ecto.Schema.Changeset.pbkdf2_hash/1,
                            &Pow.Ecto.Schema.Changeset.pbkdf2_verify/2},
    password_min_length: 10,
    password_max_length: 4096

  schema "users" do
    field :custom_field, :string

    pow_user_fields()

    timestamps()
  end

  def changeset(user_or_changeset, attrs) do
    pow_changeset(user, attrs)
  end
end

Remember to add user: MyApp.Users.User to your configuration.

Configuration options

  • :user_id_field the field to use for user id, defaults to :email, and will be validated as an email

Link to this section Summary

Link to this section Functions

Link to this function normalize_user_id_field_value(value) View Source
normalize_user_id_field_value(binary()) :: binary()
Link to this macro pow_user_fields() View Source (macro)
pow_user_fields() :: Macro.t()
Link to this function user_id_field() View Source
user_id_field() :: atom()
Link to this function user_id_field(config) View Source
user_id_field(Pow.Config.t() | Ecto.Changeset.t() | map() | atom()) :: atom()

Link to this section Callbacks

Link to this callback verify_password(arg0, binary) View Source
verify_password(Ecto.Schema.t(), binary()) :: boolean()