mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
18 lines
408 B
JavaScript
18 lines
408 B
JavaScript
'use strict';
|
|
|
|
module.exports = () => {
|
|
let _perms = [];
|
|
return {
|
|
hook(app) {
|
|
app.use((req, res, next) => {
|
|
if (req.user) req.user.permissions = _perms;
|
|
else req.user = { email: 'unknown', permissions: _perms };
|
|
next();
|
|
});
|
|
},
|
|
withPermissions(...perms) {
|
|
_perms = perms;
|
|
},
|
|
};
|
|
};
|