groups: add events to eventlog
This commit is contained in:
@@ -12,6 +12,7 @@ exports = module.exports = {
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
AuditSource = require('../auditsource.js'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
groups = require('../groups.js'),
|
||||
HttpError = require('connect-lastmile').HttpError,
|
||||
@@ -35,7 +36,7 @@ async function add(req, res, next) {
|
||||
|
||||
if (typeof req.body.name !== 'string') return next(new HttpError(400, 'name must be string'));
|
||||
|
||||
const [error, group] = await safe(groups.add({ name: req.body.name, source : '' }));
|
||||
const [error, group] = await safe(groups.add({ name: req.body.name, source : '' }, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(201, { id: group.id, name: group.name }));
|
||||
@@ -52,7 +53,7 @@ async function setName(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
if (typeof req.body.name !== 'string') return next(new HttpError(400, 'name must be a string'));
|
||||
const [error] = await safe(groups.setName(req.resource, req.body.name));
|
||||
const [error] = await safe(groups.setName(req.resource, req.body.name, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, { }));
|
||||
@@ -65,7 +66,7 @@ async function setMembers(req, res, next) {
|
||||
if (!Array.isArray(req.body.userIds)) return next(new HttpError(404, 'userIds must be an array'));
|
||||
if (req.body.userIds.some((u) => typeof u !== 'string')) return next(new HttpError(400, 'userIds array must contain strings'));
|
||||
|
||||
const [error] = await safe(groups.setMembers(req.resource, req.body.userIds, { skipSourceCheck: false }));
|
||||
const [error] = await safe(groups.setMembers(req.resource, req.body.userIds, { skipSourceCheck: false }, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, { }));
|
||||
@@ -81,7 +82,7 @@ async function list(req, res, next) {
|
||||
async function del(req, res, next) {
|
||||
assert.strictEqual(typeof req.params.groupId, 'string');
|
||||
|
||||
const [error] = await safe(groups.del(req.params.groupId));
|
||||
const [error] = await safe(groups.del(req.resource, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(204));
|
||||
|
||||
Reference in New Issue
Block a user