Skip to content

Instantly share code, notes, and snippets.

@carlyleec
Last active February 16, 2021 20:36
Show Gist options
  • Save carlyleec/38ee74d6ade9cea757fffa953251b5a3 to your computer and use it in GitHub Desktop.
Save carlyleec/38ee74d6ade9cea757fffa953251b5a3 to your computer and use it in GitHub Desktop.
...
def new(conn, _params) do
changeset = Accounts.change_user_registration(%User{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"user" => user_params}) do
case Accounts.register_user(user_params) do
{:ok, user} ->
{:ok, _} =
Accounts.deliver_user_confirmation_instructions(
user,
&Routes.user_confirmation_url(conn, :confirm, &1)
)
conn
|> put_flash(:info, "User created successfully.")
|> UserAuth.log_in_user(user)
{:error, %Ecto.Changeset{} = changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment