Commit f4c48538 authored by pdg16's avatar pdg16
Browse files

return users from user origin

parent 4447cabc
Pipeline #19917 failed with stage
in 1 minute and 31 seconds
function checkAdminLDE() {
function checkAdmin() {
return (req, res, next) => {
if(req.user.adminLDE)
if((req.user.adminLDE && req.user.origin === "LDE") || (req.user.adminSimcaqNode && req.user.origin === "SimCAQ"))
return next();
else
return res.json({access: 'Unauthorized'});
}
}
module.exports = checkAdminLDE;
\ No newline at end of file
module.exports = checkAdmin;
\ No newline at end of file
......@@ -38,7 +38,7 @@ const response = require(`${libs}/middlewares/response`);
const email = require(`${libs}/middlewares/email`);
const checkAdminLDE = require(`${libs}/middlewares/checkAdminLDE`);
const checkAdmin = require(`${libs}/middlewares/checkAdmin`);
const passport = require('passport');
......@@ -92,8 +92,8 @@ userApp.get('/role', (req, res, next) => {
next();
}, response('role'));
userApp.get('/', passport.authenticate('bearer', {session: false}), checkAdminLDE(), (req, res, next) => {
User.find((err, users) => {
userApp.get('/', passport.authenticate('bearer', {session: false}), checkAdmin(), (req, res, next) => {
User.find({"origin": req.user.origin},(err, users) => {
if(err) {
log.error(err);
return next(err);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment