Jumar.Accounts.User (Jumar v0.1.0)

View Source

Database schema for each individual registered user account.

Summary

Functions

Confirms the account by setting confirmed_at.

A user changeset for registering or changing the email.

A user changeset for changing the password.

Verifies the password.

Types

t()

@type t() :: %Jumar.Accounts.User{
  __meta__: Ecto.Schema.Metadata.t(),
  authenticated_at: term(),
  confirmed_at: DateTime.t() | nil,
  email: String.t() | nil,
  hashed_password: String.t() | nil,
  id: Jumar.Types.TypeId.t() | nil,
  inserted_at: DateTime.t() | nil,
  password: String.t() | nil,
  updated_at: DateTime.t() | nil
}

Functions

confirm_changeset(user)

Confirms the account by setting confirmed_at.

email_changeset(user, attrs, opts \\ [])

A user changeset for registering or changing the email.

It requires the email to change otherwise an error is added.

Options

  • :validate_unique - Set to false if you don't want to validate the uniqueness of the email, useful when displaying live validations. Defaults to true.

password_changeset(user, attrs, opts \\ [])

A user changeset for changing the password.

It is important to validate the length of the password, as long passwords may be very expensive to hash for certain algorithms.

Options

  • :hash_password - Hashes the password so it can be stored securely in the database and ensures the password field is cleared to prevent leaks in the logs. If password hashing is not needed and clearing the password field is not desired (like when using this changeset for validations on a LiveView form), this option can be set to false. Defaults to true.

valid_password?(arg1, password)

Verifies the password.

If there is no user or the user doesn't have a password, we call Argon2.no_user_verify/0 to avoid timing attacks.