feat(system_actor): add system_user?/1 and normalize email

Case-insensitive email comparison for system-actor detection.
This commit is contained in:
Moritz 2026-01-27 17:37:28 +01:00 committed by moritz
parent 41bc031cc6
commit 7d33acde9f
2 changed files with 35 additions and 5 deletions

View file

@ -57,7 +57,7 @@ defmodule Mv.Helpers.SystemActorTest do
|> Ash.read_one(domain: Mv.Accounts, authorize?: false) do
{:ok, user} when not is_nil(user) ->
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)
|> Ash.load!(:role, domain: Mv.Accounts, authorize?: false)
@ -68,7 +68,7 @@ defmodule Mv.Helpers.SystemActorTest do
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)
|> Ash.load!(:role, domain: Mv.Accounts, authorize?: false)
@ -373,9 +373,9 @@ defmodule Mv.Helpers.SystemActorTest do
system_actor = SystemActor.get_system_actor()
# Assign wrong role to system user
# Assign wrong role to system user (use :update_internal so bootstrap-style update is allowed)
system_user
|> Ash.Changeset.for_update(:update, %{})
|> Ash.Changeset.for_update(:update_internal, %{})
|> Ash.Changeset.manage_relationship(:role, read_only_role, type: :append_and_remove)
|> Ash.update!(actor: system_actor)