Hash :
e800e02b
Author :
Thomas de Grivel
Date :
2021-12-08T16:24:53
defmodule KmxgitWeb.UserRegistrationController do
use KmxgitWeb, :controller
alias Kmxgit.UserManager
alias Kmxgit.UserManager.User
alias KmxgitWeb.UserAuth
def new(conn, _params) do
changeset = UserManager.change_user_registration(%User{})
render(conn, "new.html", changeset: changeset)
end
def create(conn, %{"user" => user_params}) do
case UserManager.register_user(user_params) do
{:ok, user} ->
{:ok, _} =
UserManager.deliver_user_confirmation_instructions(
user,
&Routes.user_confirmation_url(conn, :edit, &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
end