entrance v0.3.1 Entrance.User
This module provider helpers functions for your app users management
Link to this section Summary
Functions
Execute this behind the scenes
Similar to Entrance.User.changeset/0
but not need the user_module
to be configured via Mix.Config
Execute this behind the scenes
Link to this section Functions
Link to this function
changeset()
Execute this behind the scenes:
YourUser.changeset(%YourUser{}, %{})
Returns an Ecto.Changeset
struct
Requires user_module
to be configured via Mix.Config
.
Example
# YourAppWeb.UserController ...
def new(conn, _params) do
conn |> render("new.html", changeset: Entrance.User.changeset)
end
Link to this function
changeset(user_module)
Similar to Entrance.User.changeset/0
but not need the user_module
to be configured via Mix.Config
Example
# YourAppWeb.UserController ...
def new(conn, _params) do
conn |> render("new.html", changeset: Entrance.User.changeset(Customer))
end
Link to this function
create(user_module \\ nil, user_params)
Execute this behind the scenes:
alias Entrance.Auth.Secret
# ...
%YourUser{}
|> YourUser.changeset(your_user_params)
|> Secret.put_session_secret()
|> YourRepo.insert()
Returns {:ok, user}
or {:error, changeset}
Requires user_module
and repo
to be configured via
Mix.Config
.
Examples
{:ok, user} = Entrance.User.create(%{"email => "joe@dirt.com", "password" => "brandyr00lz"})
If you want to use create/2
with other user schema, you can set the module directly.
{:ok, customer} = Entrance.User.create(Customer, %{"email => "joe@dirt.com", "password" => "brandyr00lz"})