Skip to content

Commit 85ae3c7

Browse files
committed
rename /selfAssign to distinguish from other judge adding endpoint
1 parent 1e345b0 commit 85ae3c7

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎common/src/types.ts‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,4 @@ export type AutoPopulatedDoc<PopulatedType> = PopulatedType & { _id: mongoose.Re
9090
* for managing permissions.
9191
*/
9292
export type AbilityAction =
93-
| "read"
94-
| "create"
95-
| "update"
96-
| "delete"
97-
| "manage"
98-
| "aggregate"
99-
| "refer";
93+
"read" | "create" | "update" | "delete" | "manage" | "aggregate" | "refer" | "selfAssign";

‎services/expo/src/permission.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const addAbilities = (): RequestHandler => (req, res, next) => {
2323
if (req.user.roles.admin || req.user.roles.member) {
2424
can("manage", "Company");
2525
can("manage", "Team");
26-
can("update", "CategoryGroup");
26+
can("selfAssign", "CategoryGroup");
2727
}
2828

2929
can("manage", "Profile", { userId: req.user.uid });

‎services/expo/src/routes/categorygroups.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ categoryGroupRoutes.route("/:id").patch(
163163
})
164164
);
165165

166+
/** (admin only), add a given judge to a given categoryGroup */
166167
categoryGroupRoutes.route("/:id/judges").post(
167168
isAdmin,
168169
asyncHandler(async (req, res) => {
@@ -212,8 +213,13 @@ categoryGroupRoutes.route("/:id").delete(
212213
})
213214
);
214215

215-
categoryGroupRoutes.route("/:id/add").post(
216-
checkAbility("update", "CategoryGroup"),
216+
/**
217+
* Self assign the current user to a given category group.
218+
* diff from the other judge assigner is that this one's open to
219+
* hexlabs members, but only handles self-assigning.
220+
*/
221+
categoryGroupRoutes.route("/:id/selfAssign").post(
222+
checkAbility("selfAssign", "CategoryGroup"),
217223
asyncHandler(async (req, res) => {
218224
const categoryGroupId = Number(req.params.id);
219225
const userId = req.user?.uid;

0 commit comments

Comments
 (0)