Skip to content

Commit 72973ce

Browse files
committed
feat(router): implement route permissions mapping
- Create a new file for defining route permissions based on user roles - Establish a centralized mapping of dashboard user roles to permitted routes - Include permissions for admin and publisher roles - Utilize the existing Routes and DashboardUserRole enums
1 parent 074c3ab commit 72973ce

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/router/route_permissions.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import 'package:core/core.dart';
2+
import 'package:flutter_news_app_web_dashboard_full_source_code/router/routes.dart';
3+
4+
/// A centralized mapping of dashboard user roles to their permitted routes.
5+
///
6+
/// This map is used by the router's redirect logic to enforce navigation
7+
/// restrictions based on the authenticated user's role.
8+
final Map<DashboardUserRole, Set<String>> routePermissions = {
9+
// Admins have access to all major sections of the dashboard.
10+
DashboardUserRole.admin: {
11+
Routes.overviewName,
12+
Routes.contentManagementName,
13+
Routes.userManagementName,
14+
Routes.appConfigurationName,
15+
},
16+
// Publishers have a more restricted access, focused on content creation
17+
// and management.
18+
DashboardUserRole.publisher: {
19+
Routes.overviewName,
20+
Routes.contentManagementName,
21+
},
22+
};

0 commit comments

Comments
 (0)