Haytni v0.0.1 Haytni View Source
Documentation for Haytni.
Link to this section Summary
Functions
Notifies plugins that the authentification failed for user
Register user from controller’s params
Convert a duration of the form {number, unit}
to seconds
Injects Ecto.Schema.field
s necessary to enabled plugins into your User schema
Used by plug to extract the current user (if any) from the HTTP request (meaning from headers, cookies or session)
To be called on (manual) login
Notifies plugins that current user is going to be logged out
Returns the mailer from application’s configuration
Helper for plugins to associate a mismatch error to fields given as keys of changeset
Returns the repo (implements Ecto.Repo) from application’s configuration
Injects the necessary routes for enabled plugins into your Router
Returns the user’s schema from application’s configuration
Update user’s registration, its own registration
Update the given user from a list of changes as Keyword
Same as update_user_with/2
but returns the updated user struct or raises if changes are invalid
This function is a callback to be called from your User.create_registration_changeset/2
so validations
and others internal tasks can be done by plugins at user’s registration
Same than validate_update_registration/2
but at registration’s edition
Link to this section Functions
authentification_failed(user :: struct() | nil) :: nil
Notifies plugins that the authentification failed for user.
If user is nil
, nothing is done.
create_user(attrs :: map(), options :: Keyword.t()) :: {:ok, %{optional(Ecto.Multi.name()) => any()}} | {:error, Ecto.Multi.name(), any(), %{optional(Ecto.Multi.name()) => any()}}
Register user from controller’s params.
Returned value is one of:
{:ok, map}
where map is the result of the internalsEcto.Multi.*
calls{:error, failed_operation, result_of_failed_operation, changes_so_far}
with:- failed_operation: the name of the operation which failed
- result_of_failed_operation: its result/returned value
- changes_so_far: same as map of the
{:ok, map}
case
The inserted user will be part of map (or eventualy changes_so_far) under the key :user
.
See Ecto.Repo.insert/3
for options.
Convert a duration of the form {number, unit}
to seconds.
unit can be one of the following:
- :second
- :minute
- :hour
- :day
- :week
- :month
- :year
Injects Ecto.Schema.field
s necessary to enabled plugins into your User schema
find_user(conn :: Plug.Conn.t()) :: {Plug.Conn.t(), struct() | nil}
Used by plug to extract the current user (if any) from the HTTP request (meaning from headers, cookies or session)
login(conn :: Plug.Conn.t(), user :: struct()) :: {:ok, Plug.Conn.t()} | {:error, String.t()}
To be called on (manual) login
Notifies plugins that current user is going to be logged out
Returns the mailer from application’s configuration
config :your_app, :haytni,
mailer: YourApp.Mailer
mark_changeset_keys_as_unmatched( changeset :: Ecto.Changeset.t(), keys :: [atom()] ) :: Ecto.Changeset.t()
Helper for plugins to associate a mismatch error to fields given as keys of changeset.
Returns an Ecto.Changeset.t
with proper errors set.
Returns the repo (implements Ecto.Repo) from application’s configuration
config :your_app, :haytni,
schema: YourApp.Repo
Injects the necessary routes for enabled plugins into your Router
Returns the user’s schema from application’s configuration
config :your_app, :haytni,
schema: YourApp.User
update_registration(user :: struct(), attrs :: map(), options :: Keyword.t()) :: {:ok, %{optional(Ecto.Multi.name()) => any()}} | {:error, Ecto.Multi.name(), any(), %{optional(Ecto.Multi.name()) => any()}}
Update user’s registration, its own registration.
Works exactly as create_user
. The only difference is the additionnal parameter: the user to update as first one.
NOTE: the callbacks of Ecto.Multi.run
added to the multi by the on_email_change/2
callback will receive from the
Map
they get as their (single) argument the following predefined elements:
- the updated user as the
:user
key - the previous email as
:old_email
:new_email
: the new email
update_user_with(user :: struct(), changes :: Keyword.t()) :: {:ok, struct()} | {:error, Ecto.Changeset.t()}
Update the given user from a list of changes as Keyword
.
Returns {:error, changeset}
if there was a validation or a known constraint error else {:ok, struct}
where struct is the updated user.
NOTE: for internal use, there isn’t any validation. Do NOT inject values from controller’s params!
Same as update_user_with/2
but returns the updated user struct or raises if changes are invalid.
validate_create_registration(changeset :: Ecto.Changeset.t()) :: Ecto.Changeset.t()
This function is a callback to be called from your User.create_registration_changeset/2
so validations
and others internal tasks can be done by plugins at user’s registration.
validate_update_registration(changeset :: Ecto.Changeset.t()) :: Ecto.Changeset.t()
Same than validate_update_registration/2
but at registration’s edition.