mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 08:47:07 +00:00
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:
@@ -2,3 +2,4 @@
|
||||
exports.jwt = require('./jwt');
|
||||
exports.authentify = require('./authentify');
|
||||
exports.access = require('./access');
|
||||
exports.operations = require('./operations');
|
||||
|
||||
12
lib/www/server/api/middleware/auth/operations.js
Normal file
12
lib/www/server/api/middleware/auth/operations.js
Normal 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
|
||||
};
|
||||
Reference in New Issue
Block a user