     end)
 
     {user, user_params}
-  end
-
-  defp extract_roles(user, params) do
-    {roles, user_params} = Access.pop(params, "roles")
-    roles = Enum.map(roles, &%{name: &1["name"]})
-            |> Enum.map(&Goncord.Role.get_or_create(&1))
-
-    {Goncord.Role.set_roles(user, roles), user_params}
   end
 
   def change_password(conn, %{"old_password" => old, "new_password" => new}) do

    end
  end

  defp extract_apps({user, params}) do
    {apps, user_params} = Access.pop(params, "apps")
    Enum.each(apps, fn({k, v}) ->
      case Goncord.Repo.get_by(Goncord.Resource, url: k) do

  alias Goncord.User

  def create(conn, user_params) do
    {roles, user_params} = Access.pop(user_params, "roles")
    changeset = User.changeset(%User{}, user_params)

    case Repo.insert(changeset) do
      {:ok, user} ->
        user = extract_roles(user, roles)

        conn
        |> put_status(:created)
        |> render("show.json", user: user)
