Entrance v0.4.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.create/2
, but returns the user struct and raises an error if user_params
is invalid.
Execute this behind the scenes
Similar to Entrance.User.create_changeset/0
but not need the user_module
to be configured via Mix.Config
Link to this section Functions
create(user_module \\ nil, user_params)
Execute this behind the scenes:
alias Entrance.Auth.Secret
# ...
%YourUser{}
|> YourUser.create_changeset(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"})
create!(user_module \\ nil, user_params)
Similar to Entrance.User.create/2
, but returns the user struct and raises an error if user_params
is invalid.
Execute this behind the scenes:
alias Entrance.Auth.Secret
# ...
%YourUser{}
|> YourUser.create_changeset(user_params)
|> Secret.put_session_secret()
|> YourRepo.insert!()
Requires user_module
and repo
to be configured via
Mix.Config
.
Examples
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.
customer = Entrance.User.create!(Customer, %{"email => "joe@dirt.com", "password" => "brandyr00lz"})
create_changeset()
Execute this behind the scenes:
YourUser.create_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.create_changeset)
end
create_changeset(user_module)
Similar to Entrance.User.create_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.create_changeset(Customer))
end