View Source Zoonk.Accounts.User (Zoonk v0.3.0-alpha)
User schema.
Link to this section Summary
Functions
Confirms the account by setting confirmed_at
.
A user changeset for changing the email.
A user changeset for changing the password.
A user changeset for registration.
A user changeset for changing the username.
Verifies the password.
Validates the current password otherwise adds an error to the changeset.
Link to this section Types
@type t() :: %Zoonk.Accounts.User{ __meta__: term(), avatar: term(), confirmed_at: term(), courses: term(), date_of_birth: term(), email: term(), first_name: term(), hashed_password: term(), id: term(), inserted_at: term(), language: term(), last_name: term(), password: term(), schools: term(), updated_at: term(), username: term() }
Link to this section Functions
@spec confirm_changeset(Ecto.Schema.t()) :: Ecto.Changeset.t()
Confirms the account by setting confirmed_at
.
@spec email_changeset(Ecto.Schema.t(), map(), Keyword.t()) :: Ecto.Changeset.t()
A user changeset for changing the email.
It requires the email to change otherwise an error is added.
@spec password_changeset(Ecto.Schema.t(), map(), Keyword.t()) :: Ecto.Changeset.t()
A user changeset for changing the password.
options
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 tofalse
. Defaults totrue
.
@spec registration_changeset(Ecto.Schema.t(), map(), Keyword.t()) :: Ecto.Changeset.t()
A user changeset for registration.
It is important to validate the length of both email and password. Otherwise databases may truncate the email without warnings, which could lead to unpredictable or insecure behaviour. Long passwords may also be very expensive to hash for certain algorithms.
options
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 tofalse
. Defaults totrue
.:validate_email
- Validates the uniqueness of the email, in case you don't want to validate the uniqueness of the email (like when using this changeset for validations on a LiveView form before submitting the form), this option can be set tofalse
. Defaults totrue
.
@spec settings_changeset(Ecto.Schema.t(), map(), Keyword.t()) :: Ecto.Changeset.t()
A user changeset for changing the username.
@spec valid_password?(Ecto.Schema.t(), String.t()) :: boolean()
Verifies the password.
If there is no user or the user doesn't have a password, we call
Bcrypt.no_user_verify/0
to avoid timing attacks.
@spec validate_current_password(Ecto.Changeset.t(), String.t()) :: Ecto.Changeset.t()
Validates the current password otherwise adds an error to the changeset.