Created
July 2, 2020 03:42
-
-
Save mchavezi/341539231086f4e67788372c4956a034 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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