User: Don't allow local users in remote changesets

This commit is contained in:
lain 2020-12-02 12:18:43 +01:00
commit a32e13e6c4
2 changed files with 20 additions and 0 deletions

View file

@ -461,7 +461,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