Skip to content

Commit

Permalink
Fix #136
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Romero Brox committed May 23, 2013
1 parent ab9344c commit df03b19
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
33 changes: 12 additions & 21 deletions lib/agentLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,17 @@ function putTransMeta(req, res) {

function postQueue(req, res) {

var errors = [];//validate.errorsTrans(req.body);
var ev = {};
var queue = req.body.queue,
user = req.body.user,
passwd = req.body.password;
var appPrefix = req.prefix;
var errors = [],//validate.errorsTrans(req.body);
ev = {},
queue = req.body.queue,
user = req.body.user,
passwd = req.body.password,
appPrefix = req.prefix,
statusCode = 0;

if (errors.length === 0) {
dataSrv.setSecHash(appPrefix, queue, user, passwd, function (err) {
if (err) {
statusCode = err.statusCode || 500;
ev = {
'queue': queue,
'postdata': req.body,
Expand All @@ -204,14 +205,12 @@ function postQueue(req, res) {
'error': err
};
emitter.emit('ACTION', ev);
logger.info('putTransMeta', [
logger.info('postQueue', [
{errors: [String(err)]},
400,
statusCode,
req.info
]);
res.send(500, [
{errors: [String(err)]}
]);
res.send(statusCode, {errors: [String(err)]});
} else {
ev = {
'queue': queue,
Expand All @@ -220,21 +219,13 @@ function postQueue(req, res) {
'timestamp': new Date()
};
emitter.emit('ACTION', ev);
logger.info('putTransMeta', [
logger.info('postQueue', [
{ok: true},
req.info
]);
res.send({ok: true});
}
});
} else {
logger.info('putTransMeta', [
{errors: errors},
400,
req.info
]);
res.send(400, {errors: errors});
}
}


Expand Down
1 change: 1 addition & 0 deletions lib/dataHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var createKey = function(db, id, value, callback) {
}
else if(val === 0) {
err = new Error(id + " exists");
err.statusCode = 403;
}
if (callback) {
return callback(err);
Expand Down

0 comments on commit df03b19

Please sign in to comment.