Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mchavezi/341539231086f4e67788372c4956a034 to your computer and use it in GitHub Desktop.

Select an option

Save mchavezi/341539231086f4e67788372c4956a034 to your computer and use it in GitHub Desktop.
defmodule MyApp.Registration do
@moduledoc """
The Registration context.
"""
alias MyApp.Subdomain.Accounts
alias MyApp.Orgs
alias MyApp.Tenants.Tenant
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.changes.tenant}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment