Skip to content

Commit

Permalink
feat(next/api): category.meta.allow property
Browse files Browse the repository at this point in the history
  • Loading branch information
sdjdd committed Apr 18, 2024
1 parent f40eee8 commit fdf13c0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions next/api/src/router/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,15 @@ router.post('/', async (ctx) => {
if (!category) {
return ctx.throw(400, `Category ${data.categoryId} is not exists`);
}
if (category.meta) {
const { allow } = category.meta;
if (typeof allow === 'string') {
const systemRoles = await roleService.getSystemRolesForUser(currentUser.id);
if (!systemRoles.includes(allow)) {
return ctx.throw(403, `You cannot create ticket with category ${category.id}`);
}
}
}

const { title: fieldTitle, details, attachments, customFields } = extractSystemFields(
data.customFields
Expand Down

0 comments on commit fdf13c0

Please sign in to comment.