Skip to content

Commit

Permalink
fixed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonSharratt committed Feb 5, 2020
1 parent ce4876b commit 1350981
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions microservices/requestApi/routes/v2/routes/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,11 @@ var getRouter = function(db){
var config = require('config');
let adminGroup = config.get("adminGroup");
if (req.user.groups.indexOf(adminGroup) === -1){
console.log("FORMIO FORBIDDEN");
res.status(403);
res.json({error: "Forbidden"});
return;
}
console.log("FORMIO ALLOWED");

var formName = req.params.formName;
formioClient.putForm(formName, req.body, function(formErr, formRes){
if (formErr){
Expand All @@ -516,26 +515,23 @@ var getRouter = function(db){
r = JSON.parse(formRes);
}catch(ex){}

try{
if (typeof(r.status) === "Number"){
res.status(r.status)
}catch(ex){}
}

res.json(r);
});
});

router.delete('/formio/:formName', function(req, res, next){
console.log("IN DELETE FORM ROUTE");
router.delete(FORMS_SUB_ROUTE+'/:formName', function(req, res, next){
var config = require('config');
var adminGroup = config.get("adminGroup");

if (req.user.groups.indexOf(adminGroup) === -1){
console.log("FORMIO FORBIDDEN");
res.status(403);
res.json({error: "Forbidden"});
return;
}
console.log("FORMIO ALLOWED");
var formName = req.params.formName;
formioClient.putForm(formName, req.body, function(formErr, formRes){
if (formErr){
Expand All @@ -548,9 +544,9 @@ var getRouter = function(db){
r = JSON.parse(formRes);
}catch(ex){}

try{
if (typeof(r.status) === "Number"){
res.status(r.status)
}catch(ex){}
}

res.json(r);
});
Expand Down

0 comments on commit 1350981

Please sign in to comment.