Commit 97d41706 authored by pdg16's avatar pdg16
Browse files

add list users route

parent 9b71575c
Pipeline #19909 failed with stage
in 1 minute and 31 seconds
function checkAdmin(origin) {
return (req, res, next) => {
if(req.user.origin === origin)
return next();
else
return res.json({access: 'Unauthorized'});
}
}
module.exports = checkAdmin;
\ No newline at end of file
......@@ -38,6 +38,8 @@ const response = require(`${libs}/middlewares/response`);
const email = require(`${libs}/middlewares/email`);
const checkAdmin = require(`${libs}/middlewares/checkAdmin`);
const passport = require('passport');
function emailSyntax(email) {
......@@ -90,8 +92,7 @@ userApp.get('/role', (req, res, next) => {
next();
}, response('role'));
/*
userApp.get('/', passport.authenticate('bearer', {session: false}), (req, res, next) => {
userApp.get('/', passport.authenticate('bearer', {session: false}), checkAdmin("LDE"), (req, res, next) => {
User.find((err, users) => {
if(err) {
log.error(err);
......@@ -109,7 +110,6 @@ userApp.get('/', passport.authenticate('bearer', {session: false}), (req, res, n
next();
});
}, response('users'));
*/
userApp.get('/me', passport.authenticate('bearer', { session: false }), (req, res, next) => {
let user = req.user.toObject();
......
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