Pow v0.1.0-alpha.6 Pow.Ecto.Schema.Changeset View Source

Handles changesets methods for Pow schema.

These methods should never be called directly, but instead the methods build in macros in Pow.Ecto.Schema should be used. This is to ensure that only compile time configuration is used.

Configuration options

  • :password_min_length - minimum password length, defaults to 10
  • :password_max_length - maximum password length, defaults to 4096
  • :password_hash_methods - the password hash and verify methods to use, defaults to:

    {&Pow.Ecto.Schema.Password.pbkdf2_hash/1,
     &Pow.Ecto.Schema.Password.pbkdf2_verify/2}

Link to this section Summary

Link to this section Functions

Link to this function current_password_changeset(user_or_changeset, params, config) View Source
current_password_changeset(
  Ecto.Schema.t() | Ecto.Changeset.t(),
  map(),
  Pow.Config.t()
) :: Ecto.Changeset.t()

Validates the current password field.

It’s only required to provide a current password if the password_hash value exists in the data struct.

Link to this function password_changeset(user_or_changeset, params, config) View Source
password_changeset(Ecto.Schema.t() | Ecto.Changeset.t(), map(), Pow.Config.t()) ::
  Ecto.Changeset.t()

Validates the password field.

The password and confirm_password params is required to be equal. A password hash is generated by using :password_hash_methods in the configuration. The password is always required if the password hash is nil, and it’s required to be between :password_min_length to :password_max_length characters long.

The password hash is only generated if the changeset is valid, but always required.

Link to this function user_id_field_changeset(user_or_changeset, params, config) View Source
user_id_field_changeset(
  Ecto.Schema.t() | Ecto.Changeset.t(),
  map(),
  Pow.Config.t()
) :: Ecto.Changeset.t()

Validates the user id field.

The user id field is always required. It will be treated as case insensitive, and it’s required to be unique. If the user id field is :email, the value will be validated as an e-mail address too.

Link to this function verify_password(map, password, config) View Source
verify_password(Ecto.Schema.t(), binary(), Pow.Config.t()) :: boolean()

Verifies a password in a struct.

The password will be verified by using the :password_hash_methods in the configuration.