Zoonk.Accounts.User (Zoonk v0.1.0-dev)

View Source

Defines the User schema.

This schema represents users in the system, storing their email and account confirmation status. It also includes changeset functions for managing user signup, email validation, and account confirmation.

For public information, we use the Zoonk.Accounts.UserProfile schema instead.

Fields

Field NameTypeDescription
year_of_birthIntegerYear of birth for legal reasons.
emailStringUser's email address.
languageEcto.EnumUser's language.
confirmed_atDateTimeWhen the account was confirmed.
authenticated_atDateTimeWhen the user was last authenticated.
inserted_atDateTimeWhen the user was created.
updated_atDateTimeWhen the user was last updated.

Summary

Functions

Confirms the account by setting confirmed_at.

A user changeset for signing up or changing the email.

Get a user's name.

A user changeset for updating a user's settings.

A user changeset for signing up.

Functions

confirm_changeset(user)

Confirms the account by setting confirmed_at.

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

A user changeset for signing up or changing the email.

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

Options

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

get_display_name(profile)

Get a user's name.

Useful for displaying the user's name. It handles the case where the user has not set a display name and falls back to the username.

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

A user changeset for updating a user's settings.

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

A user changeset for signing up.