Skip to content

Instantly share code, notes, and snippets.

@mchavezi
Created July 2, 2020 03:15
Show Gist options
  • Select an option

  • Save mchavezi/6c0df32bad97ca0dd8e1269802b60bef to your computer and use it in GitHub Desktop.

Select an option

Save mchavezi/6c0df32bad97ca0dd8e1269802b60bef to your computer and use it in GitHub Desktop.
defmodule MyApp.Registration do
@moduledoc """
The Registration context.
"""
alias MyApp.Subdomain.Accounts
alias MyApp.Orgs
def create(attrs) do
case Orgs.register_org(attrs) do
{:ok, org} ->
case Accounts.register_user(attrs) do
{:ok, user} -> {:ok, user}
{:error, %Ecto.Changeset{} = changeset} -> {:error, changeset}
end
{:error, %Ecto.Changeset{} = changeset} -> {:error, changeset}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment