entrance v0.3.2 Entrance.User

This module provider helpers functions for your app users management

Link to this section Summary

Functions

Execute this behind the scenes

Execute this behind the scenes

Similar to Entrance.User.changeset/0 but not need the user_module to be configured via Mix.Config

Link to this section Functions

Link to this function

create(user_module \\ nil, user_params)

Execute this behind the scenes:

alias Entrance.Auth.Secret

# ...
%YourUser{}
|> YourUser.create_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/1 with other user schema, you can set the module directly.

{:ok, customer} = Entrance.User.create(Customer, %{"email => "joe@dirt.com", "password" => "brandyr00lz"})
Link to this function

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
Link to this function

create_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.create_changeset(Customer))
end