feat(devices): /api/devices band + discovered review/edit endpoints
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { canAct } from '../auth/capability.js';
|
||||
import * as pendingChanges from '../db/repos/pending_changes.js';
|
||||
import { ForbiddenError } from './errors.js';
|
||||
import { ForbiddenError, UnauthorizedError } from './errors.js';
|
||||
|
||||
const METHOD_TO_ACTION = { POST: 'create', PATCH: 'update', PUT: 'update', DELETE: 'delete' };
|
||||
|
||||
@@ -15,9 +15,8 @@ export function requireWrite(entity_type) {
|
||||
}
|
||||
|
||||
export function requireOwner(req, _res, next) {
|
||||
if (req.actor?.kind !== 'user') {
|
||||
return next(new ForbiddenError('owner-only endpoint'));
|
||||
}
|
||||
if (!req.actor) return next(new UnauthorizedError('owner-only endpoint'));
|
||||
if (req.actor.kind !== 'user') return next(new ForbiddenError('owner-only endpoint'));
|
||||
next();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user