[FEATURE]: Page Permission Router Plug #388
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#388
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
Create a Phoenix plug that checks if the current user has permission to access the requested page/route. This runs before LiveView mounts.
Tasks
lib/mv_web/plugs/check_page_permission.exinit/1andcall/2conn.private[:phoenix_route]. Instead: get the route template (e.g. "/members/:id") viaPhoenix.Router.route_info(conn.private[:phoenix_router], conn.method, conn.request_path, conn.host); the:routekey holds the template. Fallback toconn.request_pathwhen there is no match (e.g. forforwardroutes).conn.assigns[:current_user]PermissionSets.get_permissions/1to get allowed pages list:require_authenticated_user; auth is done viaash_authentication_live_sessionwithon_mount. Instead: define a pipeline:require_page_permissionthat includes the plug, and use it in the same scope as the protected live routes, e.g.pipe_through [:browser, :require_page_permission]. Note: If the plug runs for the whole scope (including auth routes), exempt public paths (e.g./auth,/register,/reset,/confirm) from the page-permission check so unauthenticated users can reach the login page.Acceptance Criteria
Test Strategy (TDD)
Static Route Tests
Dynamic Route Tests
Wildcard Tests
Unauthenticated User Tests
Error Handling Tests
Test File
test/mv_web/plugs/check_page_permission_test.exs