Skip to content

Commit 3b355fa

Browse files
committed
More fixes
1 parent d2b2624 commit 3b355fa

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

plugins/dbviewer/api/api.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ var spawn = require('child_process').spawn,
152152
**/
153153
function getIndexes() {
154154
dbs[dbNameOnParam].collection(params.qstring.collection).indexes(function(err, indexes) {
155-
if (err) {
156-
common.returnOutput(params, 'Somethings went wrong');
155+
if (err || !indexes) {
156+
common.returnOutput(params, 'Failed to retrieve indexes for the collection');
157+
}
158+
else {
159+
common.returnOutput(params, { limit: indexes.length, start: 1, end: indexes.length, total: indexes.length, pages: 1, curPage: 1, collections: indexes });
157160
}
158-
common.returnOutput(params, { limit: indexes.length, start: 1, end: indexes.length, total: indexes.length, pages: 1, curPage: 1, collections: indexes });
159161
});
160162
}
161163

plugins/reports/api/api.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,17 +314,19 @@ const FEATURE_NAME = 'reports';
314314
convertToTimezone(props);
315315

316316
// TODO: Handle report type check
317-
const userApps = getUserApps(params.member);
318-
let notPermitted = false;
317+
if (props.apps && Array.isArray(props.apps) && props.apps.length > 0) {
318+
const userApps = getUserApps(params.member);
319+
let notPermitted = false;
319320

320-
for (var i = 0; i < props.apps.length; i++) {
321-
if (userApps.indexOf(props.apps[i]) === -1) {
322-
notPermitted = true;
321+
for (var i = 0; i < props.apps.length; i++) {
322+
if (userApps.indexOf(props.apps[i]) === -1) {
323+
notPermitted = true;
324+
}
323325
}
324-
}
325326

326-
if (notPermitted && !params.member.global_admin) {
327-
return common.returnMessage(params, 401, 'User does not have right to access this information');
327+
if (notPermitted && !params.member.global_admin) {
328+
return common.returnMessage(params, 401, 'User does not have right to access this information');
329+
}
328330
}
329331
common.db.collection('reports').findOne(recordUpdateOrDeleteQuery(params, id), function(err_update, report) {
330332
if (err_update) {

0 commit comments

Comments
 (0)