Fix System missing system actor in prod and prevent deletion #379

Merged
moritz merged 12 commits from fix/system_actor into main 2026-01-27 17:54:49 +01:00
Showing only changes of commit 92ee7fcc63 - Show all commits

View file

@ -268,9 +268,9 @@ case Accounts.User
|> Ash.read_one(domain: Mv.Accounts, authorize?: false) do
{:ok, existing_system_user} when not is_nil(existing_system_user) ->
# System user already exists - ensure it has admin role
# Use authorize?: false for bootstrap
# Use authorize?: false for bootstrap; :update_internal bypasses system-user modification block
existing_system_user
|> Ash.Changeset.for_update(:update, %{})
|> Ash.Changeset.for_update(:update_internal, %{})
|> Ash.Changeset.manage_relationship(:role, admin_role, type: :append_and_remove)
|> Ash.update!(authorize?: false)
@ -287,7 +287,7 @@ case Accounts.User
upsert_identity: :unique_email,
authorize?: false
)
|> Ash.Changeset.for_update(:update, %{})
|> Ash.Changeset.for_update(:update_internal, %{})
|> Ash.Changeset.manage_relationship(:role, admin_role, type: :append_and_remove)
|> Ash.update!(authorize?: false)