Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.updateManagedTenant = function(req, res) {
var tenant = res.locals.tenant;
if(!tenant) {
rollbar.handleError("This shouldn't happen", req);
res.status(400).send({ message: errorHandler.getErrorMessage("This shouldn't happen") });
} else {
tenant = _.extend(tenant, req.body);
tenant.updated = Date.now();
tenant.save()
.then(function (tenant) {
res.json(tenant);
res.end(); // important to update session
})
.catch(function (err) {
rollbar.handleError(err, req);
res.status(400).send({ message: errorHandler.getErrorMessage(err) });
});
}
_this.requiresLogin(req, res, function() {
if (_.intersection(req.user.roles, roles).length) {
return next();
} else {
// [TODO] reset this.
rollbar.handleError('User is not authorized', req);
return res.status(403).send({
message: 'User is not authorized'
});/*
return next();*/
}
});
};
// if there is a logged in, admin user OR if the tenant has sharing enabled
if( (req.user && _.intersection(req.user.roles, ['admin']).length) || tenant.sharing.enabled ) {
req.tempUser = {
fullName: tenant.fullName,
phone: tenant.phone,
address: tenant.address,
unit: tenant.unit,
borough: tenant.borough,
geo: tenant.geo,
activity: tenant.activity,
problems: tenant.problems
};
next();
} else {
// [TODO] make this an adequate response page
rollbar.handleError('Unauthorized request', req);
return res.status(403).send({ message: 'Unauthorized request.' });
}
})
.catch(function (err) {
.catch(function (err) {
rollbar.handleError(err);
res.status(400).send(err);
});
} // no error from passport
.catch(function(err) {
var durationString = moment.utc(moment.utc() - startTime).format("HH:mm:ss.SSS");
log.error(`${monthString}: Something went terribly wrong after ${durationString}`);
log.error(err);
log.error(err.stack);
rollbar.handleError(err);
process.exit();
});
exports.rejectHandler = function (err) {
rollbar.handleError(err)
log.error(err)
log.error(err.message)
log.error(err.stack)
log.error('Aborting run.')
process.exit(1)
}
.fail(function (err) {
rollbar.handleError(err, req);
res.status(400).send(err);
});
plugin.on('request-error', (request, err) => {
Rollbar.handleError(err, request);
});
if (tableId.indexOf('drb_catchment') >= 0) {
req.params.sql = getSqlForDRBCatchmentByTableId(tableId);
}
if (tableId.indexOf('nhd_quality') >= 0) {
req.params.table = tables[tableId];
req.params.sql = getSqlForStreamByReq(req);
}
req.params.dbname = dbName;
req.params.style = styles;
req.params.interactivity = interactivity[tableName];
callback(null, req);
} catch (ex) {
rollbar.handleError(ex, req);
callback(ex, null);
}
}
};
.catch(function (err) {
rollbar.handleError(errorHandler.getErrorMessage(err), req);
return res.status(400).send({
message: errorHandler.getErrorMessage(err)
});
});
};