-
Notifications
You must be signed in to change notification settings - Fork 64
/
RoutePermissions.ts
92 lines (84 loc) · 2.42 KB
/
RoutePermissions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { PERMISSIONS } from "../model";
import { addPermissionsToRoutes, IRoutePermissions } from "./services/utils";
import routes, { IRoute } from "./routes";
const RoutePermissions: IRoutePermissions = {};
const publicOnlyRoutes: IRoute[] = [
routes.home,
routes.about,
routes.donate,
routes.login,
routes.organizer.signup,
routes.request.start,
routes.request.foodbox,
routes.request.success.donation,
routes.request.success.payment,
routes.request.error,
routes.user.signup,
routes.unauthorized,
routes.pageNotFound,
];
const authenticatedRoutes: IRoute[] = [
routes.logout,
routes.organizer.dashboard.home,
routes.missions.createdByUser,
routes.missions.createNew,
routes.missions.completed,
routes.missions.delivered,
routes.missions.details,
routes.missions.feedback,
routes.organizer.dashboard.home,
routes.organizer.dashboard.missions,
routes.organizer.dashboard.recipients,
routes.organizer.dashboard.volunteers,
routes.user.profile,
routes.volunteer.status,
routes.volunteer.dashboard.home,
routes.recipient.dashboard.home,
routes.recipient.dashboard.submitted,
routes.recipient.dashboard.completed,
];
// Public routes
addPermissionsToRoutes([PERMISSIONS.PUBLIC], publicOnlyRoutes, RoutePermissions);
addPermissionsToRoutes([PERMISSIONS.BECOME_VOLUNTEER], [routes.user.signup], RoutePermissions);
// Authenticated routes
addPermissionsToRoutes([PERMISSIONS.AUTHENTICATED], authenticatedRoutes, RoutePermissions);
// Mission-related routes
addPermissionsToRoutes(
[PERMISSIONS.VIEW_MISSIONS],
[
routes.volunteer.dashboard.home,
routes.missions.details,
routes.missions.createdByUser,
routes.missions.completed,
routes.missions.delivered,
routes.missions.feedback,
],
RoutePermissions
);
addPermissionsToRoutes(
[PERMISSIONS.CREATE_NEW_MISSIONS],
[routes.missions.createNew],
RoutePermissions
);
// Organizers-related routes
addPermissionsToRoutes(
[PERMISSIONS.VIEW_ORGANIZER_DASHBOARD],
[routes.organizer.dashboard.home],
RoutePermissions
);
addPermissionsToRoutes(
[PERMISSIONS.VIEW_ALL_MISSIONS],
[routes.organizer.dashboard.missions],
RoutePermissions
);
addPermissionsToRoutes(
[PERMISSIONS.VIEW_ALL_RECIPIENTS],
[routes.organizer.dashboard.recipients],
RoutePermissions
);
addPermissionsToRoutes(
[PERMISSIONS.VIEW_ALL_VOLUNTEERS],
[routes.organizer.dashboard.volunteers],
RoutePermissions
);
export default RoutePermissions;