[FEATURE]: Apply UI Authorization to Existing LiveViews #400
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#400
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:
Update all existing LiveViews (Member, User, and where applicable CustomFieldValue, CustomField) to use authorization helpers for conditional rendering. Use the same pattern as Role and Group LiveViews (which already use
can?/3andcan_access_page?/2).Tasks:
Member LiveViews:
can?(@current_user, :create, Mv.Membership.Member)).can?(@current_user, :update, member)/can?(@current_user, :destroy, member)).can?(@current_user, :update, @member)).User LiveViews:
can?so UI matches permissions (defense in depth).can?(@current_user, :update, @user); other users: only admin). Page access for own vs. other is already enforced by plug.can?usage for member-linking section; ensure overall edit visibility is consistent with update permission.CustomFieldValue LiveViews:
/custom_field_valuesroutes in the router yet (seedocs/page-permission-route-coverage.md). When CustomFieldValue LiveViews or embedded CustomFieldValue UI exist: hide create/edit/delete based on permissions (same pattern as Member:can?for create, and per-record for update/destroy with scope :linked where applicable).CustomField LiveViews:
/custom_fieldsroutes in the router yet. When CustomField LiveViews or embedded CustomField management UI exist: all users can view; only admin can create/edit/delete (can?(@current_user, :create|:update|:destroy, Mv.Membership.CustomField)).Sidebar (not Navbar):
lib/mv_web/components/layouts/sidebar.ex), not a classic Navbar. Update it to use authorization helpers:can_access_page?(@current_user, "/members")).can_access_page?(@current_user, "/membership_fee_types")).can_access_page?(@current_user, "/admin/roles")or/usersor/groupsetc.). Alternatively: show each subitem (Users, Groups, Roles, Fee Settings, Settings) only whencan_access_page?(@current_user, "<path>")for that path.Test all updated views with all 5 role types (Mitglied, Vorstand, Kassenwart, Buchhaltung, Admin).
Acceptance Criteria:
can?/3(and where relevantcan_access_page?/2) for conditional rendering.Test Strategy (TDD):
Member Index – Mitglied (own_data):
Member Index – Vorstand (read_only):
Member Index – Kassenwart (normal_user):
Member Index – Admin:
User Index / Show:
can?.can?(@current_user, :update, @user).Sidebar (all roles):
Note: Exact sidebar entries depend on current router and permission sets (e.g. no "Properties" in current sidebar; add/align names if routes change).
CustomFieldValue / CustomField (when UI exists):
can?allows; view when read is allowed.Test Files:
test/mv_web/live/member_live_authorization_test.exstest/mv_web/live/user_live_authorization_test.exstest/mv_web/live/custom_field_value_live_authorization_test.exs(when CustomFieldValue LiveViews/routes exist)test/mv_web/live/custom_field_live_authorization_test.exs(when CustomField LiveViews/routes exist)test/mv_web/components/sidebar_authorization_test.exs(Sidebar, not Navbar)