Commit 4447cabc authored by pdg16's avatar pdg16
Browse files

fix checkAdminLDE

parent 97d41706
Pipeline #19911 failed with stage
in 1 minute and 37 seconds
function checkAdmin(origin) {
function checkAdminLDE() {
return (req, res, next) => {
if(req.user.origin === origin)
if(req.user.adminLDE)
return next();
else
return res.json({access: 'Unauthorized'});
}
}
module.exports = checkAdmin;
\ No newline at end of file
module.exports = checkAdminLDE;
\ No newline at end of file
......@@ -38,7 +38,7 @@ const response = require(`${libs}/middlewares/response`);
const email = require(`${libs}/middlewares/email`);
const checkAdmin = require(`${libs}/middlewares/checkAdmin`);
const checkAdminLDE = require(`${libs}/middlewares/checkAdminLDE`);
const passport = require('passport');
......@@ -92,7 +92,7 @@ userApp.get('/role', (req, res, next) => {
next();
}, response('role'));
userApp.get('/', passport.authenticate('bearer', {session: false}), checkAdmin("LDE"), (req, res, next) => {
userApp.get('/', passport.authenticate('bearer', {session: false}), checkAdminLDE(), (req, res, next) => {
User.find((err, users) => {
if(err) {
log.error(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