diff --git a/server/src/configure.js b/server/src/configure.js index 48b38e8..61fccf5 100644 --- a/server/src/configure.js +++ b/server/src/configure.js @@ -1,6 +1,6 @@ // load the .env.development file ; it loads a bunch of environment variables // we are not doing this for production, where the variables are coming from the actual environment -if ((process.env.NODE_ENV || "production") !== 'production' || process.env.FORCE_DOTENV==1 || process.env.FORCE_DOTENV=="1" ){ +if (process.env.NODE_ENV !== 'production' || process.env.FORCE_DOTENV==1 || process.env.FORCE_DOTENV=="1" ){ console.log(`Importing .env file : ${__dirname}/../.env.${process.env.NODE_ENV}` ) require('dotenv').config({ path: `${__dirname}/../.env.${process.env.NODE_ENV}` }) } @@ -20,6 +20,7 @@ const swaggerDocument = require('./swagger.json'); const bodyParser = require('body-parser'); // a plugin to help with authentication and authorization const passport = require('passport'); + // a small custom middleware to check whether the user has access to routes const checkSettingsMiddleware = require('./lib/common').checkSettingsMiddleware const checkLogsMiddleware = require('./lib/common').checkLogsMiddleware diff --git a/server/src/controllers/credential.controller.js b/server/src/controllers/credential.controller.js index 896d4db..f22e220 100644 --- a/server/src/controllers/credential.controller.js +++ b/server/src/controllers/credential.controller.js @@ -45,7 +45,7 @@ exports.update = function(req, res) { res.status(400).send({ error:true, message: 'Please provide all required fields' }); }else{ Credential.update(new Credential(req.body),req.params.id) - .then((credential)=>{res.json(new RestResult("success","credential updated",null,""))}) + .then(()=>{res.json(new RestResult("success","credential updated",null,""))}) .catch((err)=>{ res.json(new RestResult("error","failed to update credential",null,err.toString())) }) } }; diff --git a/server/src/controllers/repository.controller.js b/server/src/controllers/repository.controller.js index 993adc5..69c639d 100644 --- a/server/src/controllers/repository.controller.js +++ b/server/src/controllers/repository.controller.js @@ -51,7 +51,7 @@ exports.reset = function(req, res) { Repository.reset(req.params.name) .then(()=>{res.json(new RestResult("success","repository reset",null,""))}) .catch((err)=>{ res.json(new RestResult("error","failed to reset repository",null,err.toString())) }) - }; +}; exports.pull = function(req, res) { Repository.pull(req.params.name) .then(()=>{res.json(new RestResult("success","repository pulled",null,""))}) diff --git a/server/src/db/create_oidc_table.sql b/server/src/db/create_oidc_table.sql index 5de4837..0d2c47a 100644 --- a/server/src/db/create_oidc_table.sql +++ b/server/src/db/create_oidc_table.sql @@ -7,4 +7,3 @@ CREATE TABLE `oidc` ( `enabled` tinyint(4) DEFAULT NULL, `groupfilter` varchar(250) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - diff --git a/server/src/functions/default.js b/server/src/functions/default.js index a727365..b239b88 100644 --- a/server/src/functions/default.js +++ b/server/src/functions/default.js @@ -1,6 +1,5 @@ - - // export default functions that are handy and usable with the javascrip expression field - // expand if you need, you will to do a rebuild +// export default functions that are handy and usable with the javascrip expression field +// expand if you need, you will to do a rebuild const https=require('https') const axios=require("axios") const fs = require("fs") diff --git a/server/src/lib/common.js b/server/src/lib/common.js index dfc8304..6b57541 100644 --- a/server/src/lib/common.js +++ b/server/src/lib/common.js @@ -68,16 +68,16 @@ Helpers.checkCertificate=function(cert){ } // a middleware in the routes to check if use is administrator Helpers.checkAdminMiddleware = (req, res, next) => { - try{ - if(!req.user.user.roles.includes("admin")) { - res.status(401).json(new restResult("error","No access",null,"You are not an admin")) - } else { - //logger.debug("You are admin, access to user management") - next() - } - }catch(e){ - res.status(401).json(new restResult("error","No access",null,"You are not an admin")) - } + try{ + if(!req.user.user.roles.includes("admin")) { + res.status(401).json(new restResult("error","No access",null,"You are not an admin")) + } else { + //logger.debug("You are admin, access to user management") + next() + } + }catch(e){ + res.status(401).json(new restResult("error","No access",null,"You are not an admin")) + } } Helpers.checkSettingsMiddleware = (req, res, next) => { try {