User: Don't allow local users in remote changesets
[akkoma] / lib / pleroma / user.ex
index bcd5256c8e0d51203e6a00aab2ee974e2c6d1da3..9222b5b2aaa22440d6fbe01831ed46dc43fd7594 100644 (file)
@@ -472,7 +472,20 @@ defmodule Pleroma.User do
     |> validate_format(:nickname, @email_regex)
     |> validate_length(:bio, max: bio_limit)
     |> validate_length(:name, max: name_limit)
+    |> validate_inclusion(:local, [true])
     |> validate_fields(true)
+    |> validate_non_local()
+  end
+
+  defp validate_non_local(cng) do
+    local? = get_field(cng, :local)
+
+    if local? do
+      cng
+      |> add_error(:local, "User is local, can't update with this changeset.")
+    else
+      cng
+    end
   end
 
   def update_changeset(struct, params \\ %{}) do