[FEATURE]: Member Email Validation for Linked Members #397
Labels
No labels
bug
duplicate
enhancement
help wanted
high priority
invalid
L
low priority
M
medium priority
needs refinement
optional
question
S
UX research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: local-it/mitgliederverwaltung#397
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Implement special validation: Only admins, or the user linked to that member, can edit a member’s email when that member is linked to a user. This prevents breaking email synchronization for other users’ accounts while allowing users to change their own linked member’s email (which syncs to their own user).
Tasks
lib/membership/member.ex(Member resource; domainMv.Membership).validationsblock that runs only when the email attribute is changing on update (e.g. viawhere: [changing(:email)], on: [:update]or equivalent Ash 3 syntax).Mv.Membership.Member.Validations.EmailChangePermission, or as an inline validation):member_id == member.id), allow the change.:all(admin), oractor.member_id == changeset.data.id).PermissionSets.get_permissions/1(via the actor’s rolepermission_set_name) to determine whether the actor has User.update with scope:all. For “own linked member”, checkactor.member_id == changeset.data.id. Do not use the system actor as a fallback when the actor is missing; treat missing actor as not allowed.:userrelationship or resolve the linked user fromchangeset.data); the Member resource hashas_one :userand the link is stored on User asmember_id.Acceptance Criteria
Test Strategy (TDD)
Unlinked member
member.user/ linked user is nil).Linked member – another user’s member
Linked member – own member
No-op / other fields
Test file
test/mv/membership/member_email_validation_test.exsReuse helpers from
test/mv/membership/member_policies_test.exs(e.g.create_user_with_permission_set,create_linked_member_for_user,create_unlinked_member) where appropriate.