Document System Actor pattern in code guidelines
Add section explaining when and how to use system actor for systemic operations. Include examples and distinction between user mode and system mode.
This commit is contained in:
parent
481e82d541
commit
8eb05c8a6a
3 changed files with 73 additions and 8 deletions
|
|
@ -79,7 +79,10 @@ defmodule Mv.Helpers.SystemActorTest do
|
|||
|> Ash.load!(:role, domain: Mv.Accounts)
|
||||
|
||||
_ ->
|
||||
Accounts.create_user!(%{email: admin_email}, upsert?: true, upsert_identity: :unique_email)
|
||||
Accounts.create_user!(%{email: admin_email},
|
||||
upsert?: true,
|
||||
upsert_identity: :unique_email
|
||||
)
|
||||
|> Ash.Changeset.for_update(:update, %{})
|
||||
|> Ash.Changeset.manage_relationship(:role, admin_role, type: :append_and_remove)
|
||||
|> Ash.update!()
|
||||
|
|
@ -152,6 +155,7 @@ defmodule Mv.Helpers.SystemActorTest do
|
|||
end
|
||||
|
||||
admin_email = System.get_env("ADMIN_EMAIL") || "admin@localhost"
|
||||
|
||||
case Accounts.User
|
||||
|> Ash.Query.filter(email == ^admin_email)
|
||||
|> Ash.read_one(domain: Mv.Accounts) do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue