Add auth.operations middleware.

Adds an array of allowed operations on given context to the request
under `req.user.operations`.
This commit is contained in:
D. Berge
2025-07-13 00:02:48 +02:00
parent 1295ec2ee3
commit b7ae657137
2 changed files with 13 additions and 0 deletions

View File

@@ -2,3 +2,4 @@
exports.jwt = require('./jwt');
exports.authentify = require('./authentify');
exports.access = require('./access');
exports.operations = require('./operations');

View File

@@ -0,0 +1,12 @@
const { allowedOperations } = require('../../../lib/db/project/organisations');
async function operations (req, res, next) {
if (req.user) {
req.user.operations = await allowedOperations(req.user?.organisations, req.params.project ?? null);
}
next();
}
module.exports = {
operations
};