@@ -20,12 +20,31 @@ const accountRole = {
2020 ]
2121} ;
2222
23+ const hackboardRestrictedRoutes = [ // hackboard permissions is all staff routes minus these routes
24+ Constants . Routes . hackerRoutes . postAnySendWeekOfEmail ,
25+ Constants . Routes . hackerRoutes . postSelfSendWeekOfEmail ,
26+ Constants . Routes . hackerRoutes . postAnySendDayOfEmail ,
27+ Constants . Routes . hackerRoutes . postSelfSendDayOfEmail ,
28+ Constants . Routes . hackerRoutes . patchAcceptHackerById ,
29+ Constants . Routes . hackerRoutes . patchAcceptHackerByEmail ,
30+ Constants . Routes . hackerRoutes . patchAcceptHackerByArrayOfIds ,
31+ Constants . Routes . hackerRoutes . patchAnyStatusById ,
32+ Constants . Routes . settingsRoutes . getSettings ,
33+ Constants . Routes . settingsRoutes . patchSettings
34+ ] ;
35+
2336const adminRole = {
2437 _id : mongoose . Types . ObjectId . createFromTime ( 1 ) ,
2538 name : Constants . General . STAFF ,
2639 routes : Constants . Routes . listAllRoutes ( )
2740} ;
2841
42+ const hackboardRole = {
43+ _id : mongoose . Types . ObjectId . createFromTime ( 9 ) ,
44+ name : "Hackboard" ,
45+ routes : createHackboardRoutes ( )
46+ } ;
47+
2948const hackerRole = {
3049 _id : mongoose . Types . ObjectId . createFromTime ( 2 ) ,
3150 name : Constants . General . HACKER ,
@@ -143,6 +162,15 @@ const singularRoles = createAllSingularRoles();
143162const allRolesObject = createAllRoles ( ) ;
144163const allRolesArray = Object . values ( allRolesObject ) ;
145164
165+ function createHackboardRoutes ( ) {
166+ const restrictedRouteIds = new Set (
167+ hackboardRestrictedRoutes . map ( ( route ) => route . _id . toString ( ) )
168+ ) ;
169+ return Constants . Routes . listAllRoutes ( ) . filter ( ( route ) => {
170+ return ! restrictedRouteIds . has ( route . _id . toString ( ) ) ;
171+ } ) ;
172+ }
173+
146174/**
147175 * Creates all the roles that are of a specific uri and request type
148176 * @return {Role[] }
@@ -185,6 +213,7 @@ function createAllRoles() {
185213 let allRolesObject = {
186214 accountRole : accountRole ,
187215 adminRole : adminRole ,
216+ hackboardRole : hackboardRole ,
188217 hackerRole : hackerRole ,
189218 volunteerRole : volunteerRole ,
190219 sponsorT1Role : sponsorT1Role ,
@@ -208,6 +237,7 @@ function createAllRoles() {
208237module . exports = {
209238 accountRole : accountRole ,
210239 adminRole : adminRole ,
240+ hackboardRole : hackboardRole ,
211241 hackerRole : hackerRole ,
212242 volunteerRole : volunteerRole ,
213243 sponsorT1Role : sponsorT1Role ,
0 commit comments