Vereinfacht accounting software API closes #431 #432

Merged
moritz merged 31 commits from feature/vereinfacht_api into main 2026-02-23 21:18:46 +01:00
2 changed files with 18 additions and 3 deletions
Showing only changes of commit 1188320844 - Show all commits

View file

@ -333,10 +333,10 @@ defmodule Mv.Membership.Member do
authorize_if Mv.Authorization.Checks.HasPermission authorize_if Mv.Authorization.Checks.HasPermission
end end
# Internal sync action: allow setting vereinfacht_contact_id (used only by SyncContact change). # Internal sync action: only SystemActor may set vereinfacht_contact_id (used by SyncContact change).
policy action(:set_vereinfacht_contact_id) do policy action(:set_vereinfacht_contact_id) do
description "Allow internal sync to set Vereinfacht contact ID" description "Only system actor may set Vereinfacht contact ID"
authorize_if always() authorize_if Mv.Authorization.Checks.ActorIsSystemUser
end end
# CREATE/UPDATE: Forbid memberuser link unless admin, then check permissions # CREATE/UPDATE: Forbid memberuser link unless admin, then check permissions

View file

@ -0,0 +1,15 @@
defmodule Mv.Authorization.Checks.ActorIsSystemUser do
@moduledoc """
Policy check: true only when the actor is the system user (e.g. system@mila.local).
Used to restrict internal actions (e.g. Member.set_vereinfacht_contact_id) so that
only code paths using SystemActor can perform them, not regular admins.
"""
use Ash.Policy.SimpleCheck
@impl true
def describe(_opts), do: "actor is the system user"
@impl true
def match?(actor, _context, _opts), do: Mv.Helpers.SystemActor.system_user?(actor)
end