fix(projects): use real events.edit permission for project writes
The project create/update/assign routes required 'events.manage', which is not a real permission (the event perms are view/create/edit/delete/archive). Since it's absent from the permissions table, even super_admin's all-perms set excluded it, so every write 403'd with 'Insufficient permissions'. Switched the write routes to the existing 'events.edit'. (Reads keep events.view; cockpit doc gating + email actions already use real keys.)
This commit is contained in:
@@ -49,7 +49,7 @@ router.get('/', requirePermission('events.view'), handleAsync(async (req, res) =
|
|||||||
|
|
||||||
// Create
|
// Create
|
||||||
router.post('/',
|
router.post('/',
|
||||||
requirePermission('events.manage'),
|
requirePermission('events.edit'),
|
||||||
[body('name').isString().trim().isLength({ min: 1, max: 255 }), body('customerAccountId').optional({ values: 'falsy' }).isInt({ min: 1 })],
|
[body('name').isString().trim().isLength({ min: 1, max: 255 }), body('customerAccountId').optional({ values: 'falsy' }).isInt({ min: 1 })],
|
||||||
handleAsync(async (req, res) => {
|
handleAsync(async (req, res) => {
|
||||||
validateRequest(req);
|
validateRequest(req);
|
||||||
@@ -71,7 +71,7 @@ router.get('/:id', requirePermission('events.view'), [param('id').isInt({ min: 1
|
|||||||
|
|
||||||
// Update
|
// Update
|
||||||
router.put('/:id',
|
router.put('/:id',
|
||||||
requirePermission('events.manage'),
|
requirePermission('events.edit'),
|
||||||
[
|
[
|
||||||
param('id').isInt({ min: 1 }),
|
param('id').isInt({ min: 1 }),
|
||||||
body('name').optional().isString().trim().isLength({ min: 1, max: 255 }),
|
body('name').optional().isString().trim().isLength({ min: 1, max: 255 }),
|
||||||
@@ -91,7 +91,7 @@ router.put('/:id',
|
|||||||
|
|
||||||
// Attach an event to the project
|
// Attach an event to the project
|
||||||
router.post('/:id/events',
|
router.post('/:id/events',
|
||||||
requirePermission('events.manage'),
|
requirePermission('events.edit'),
|
||||||
[param('id').isInt({ min: 1 }), body('eventId').isInt({ min: 1 })],
|
[param('id').isInt({ min: 1 }), body('eventId').isInt({ min: 1 })],
|
||||||
handleAsync(async (req, res) => {
|
handleAsync(async (req, res) => {
|
||||||
validateRequest(req);
|
validateRequest(req);
|
||||||
@@ -102,7 +102,7 @@ router.post('/:id/events',
|
|||||||
|
|
||||||
// Attach a quote to the project (quotes carry no event_id — migration 121).
|
// Attach a quote to the project (quotes carry no event_id — migration 121).
|
||||||
router.post('/:id/quotes',
|
router.post('/:id/quotes',
|
||||||
requirePermission('events.manage'),
|
requirePermission('events.edit'),
|
||||||
[param('id').isInt({ min: 1 }), body('quoteId').isInt({ min: 1 })],
|
[param('id').isInt({ min: 1 }), body('quoteId').isInt({ min: 1 })],
|
||||||
handleAsync(async (req, res) => {
|
handleAsync(async (req, res) => {
|
||||||
validateRequest(req);
|
validateRequest(req);
|
||||||
@@ -113,7 +113,7 @@ router.post('/:id/quotes',
|
|||||||
|
|
||||||
// Attach a contract to the project.
|
// Attach a contract to the project.
|
||||||
router.post('/:id/contracts',
|
router.post('/:id/contracts',
|
||||||
requirePermission('events.manage'),
|
requirePermission('events.edit'),
|
||||||
[param('id').isInt({ min: 1 }), body('contractId').isInt({ min: 1 })],
|
[param('id').isInt({ min: 1 }), body('contractId').isInt({ min: 1 })],
|
||||||
handleAsync(async (req, res) => {
|
handleAsync(async (req, res) => {
|
||||||
validateRequest(req);
|
validateRequest(req);
|
||||||
|
|||||||
Reference in New Issue
Block a user