Skip to content

Commit a545e21

Browse files
committed
[feature/crud-context] final corrections.
- added missing route permission checks for views. - eslint fixes.
1 parent d1a33e7 commit a545e21

File tree

26 files changed

+8800
-543
lines changed

26 files changed

+8800
-543
lines changed

api/parts/mgmt/users.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ var usersApi = {},
99
mail = require('./mail.js'),
1010
countlyConfig = require('./../../../frontend/express/config.js'),
1111
plugins = require('../../../plugins/pluginManager.js'),
12-
{ hasUpdateRight, hasDeleteRight, hasAdminAccess, getUserApps, getAdminApps } = require('./../../utils/rights.js');
12+
{ hasAdminAccess, getUserApps, getAdminApps } = require('./../../utils/rights.js');
1313

1414
const countlyCommon = require('../../lib/countly.common.js');
1515
const log = require('../../utils/log.js')('core:mgmt.users');
1616
const _ = require('lodash');
17-
const FEATURE_NAME = 'global_users';
1817

1918
//for password checking when deleting own account. Could be removed after merging with next
2019
var argon2 = require('argon2');

api/utils/requestProcessor.js

-1
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,6 @@ const processRequest = (params) => {
19541954
}
19551955
else {
19561956
params.truncateEventValuesList = true;
1957-
19581957
validateRead(params, 'core', countlyApi.data.fetch.prefetchEventData, params.qstring.method);
19591958
}
19601959
}

api/utils/rights.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ exports.hasCreateRight = function(feature, app_id, member) {
870870
};
871871

872872
exports.hasReadRight = function(feature, app_id, member) {
873-
return member.global_admin || member.permission.r[app_id].allowed[feature] || member.permission.r[app_id].all;
873+
return member.global_admin || member.permission.r[app_id].allowed[feature] || member.permission.r[app_id].all;
874874
};
875875

876876
exports.hasUpdateRight = function(feature, app_id, member) {

extend/mail.example.js

-85
This file was deleted.

frontend/express/public/javascripts/countly/countly.auth.js

+29-23
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
var fa = featureName.split('_');
3636
var ret = '';
3737
for (var i = 0; i < fa.length; i++) {
38-
ret += fa[i].substr(0, 1).toUpperCase() + fa[i].substr(1, fa[i].length -1) + ' ';
38+
ret += fa[i].substr(0, 1).toUpperCase() + fa[i].substr(1, fa[i].length - 1) + ' ';
3939
}
4040
return ret;
4141
}
@@ -225,7 +225,9 @@
225225
countlyAuth.updatePermissionByType = function(permissionType, permissionObject, processFlag) {
226226
permissionObject[permissionType].all = processFlag;
227227
for (var i = 0; i < countlyAuth.features.length; i++) {
228-
if (permissionType === 'r' && countlyAuth.features[i] === 'core') continue;
228+
if (permissionType === 'r' && countlyAuth.features[i] === 'core') {
229+
continue;
230+
}
229231
if (processFlag) {
230232
permissionObject[permissionType].allowed[countlyAuth.features[i]] = processFlag;
231233
}
@@ -239,8 +241,12 @@
239241
countlyAuth.giveFeaturePermission = function(permissionType, feature, permissionObject) {
240242
var allCheck = true;
241243
for (var i = 0; i < countlyAuth.features.length; i++) {
242-
if (permissionType === 'r' && countlyAuth.features[i] === 'core') continue;
243-
if (!permissionObject[permissionType].allowed[countlyAuth.features[i]]) allCheck = false;
244+
if (permissionType === 'r' && countlyAuth.features[i] === 'core') {
245+
continue;
246+
}
247+
if (!permissionObject[permissionType].allowed[countlyAuth.features[i]]) {
248+
allCheck = false;
249+
}
244250
}
245251
permissionObject[permissionType].all = allCheck;
246252
permissionObject[permissionType].allowed[feature] = true;
@@ -279,38 +285,38 @@
279285

280286
$('#manage-users-admin-app-selector')[0].selectize.setValue(checked_admin_apps);
281287

282-
for (var i = 0; i < user_apps.length; i++) {
288+
for (var i0 = 0; i0 < user_apps.length; i0++) {
283289
checked_user_apps = [];
284-
for (var j = 0; j < user_apps[i].length; j++) {
285-
if (countlyGlobal.apps[user_apps[i][j]]) {
286-
checked_user_apps.push(user_apps[i][j]);
290+
for (var j0 = 0; j0 < user_apps[i0].length; j0++) {
291+
if (countlyGlobal.apps[user_apps[i0][j0]]) {
292+
checked_user_apps.push(user_apps[i0][j0]);
287293
}
288294
}
289295

290-
$(parent_el + ' #user-app-selector-' + i)[0].selectize.setValue(checked_user_apps);
296+
$(parent_el + ' #user-app-selector-' + i0)[0].selectize.setValue(checked_user_apps);
291297

292-
for (var j = 0; j < countlyAuth.types.length; j++) {
293-
if (user_apps[i].length > 0) {
294-
if (permission_object[countlyAuth.types[j]][user_apps[i][0]].all) {
298+
for (var j1 = 0; j1 < countlyAuth.types.length; j1++) {
299+
if (user_apps[i0].length > 0) {
300+
if (permission_object[countlyAuth.types[j1]][user_apps[i0][0]].all) {
295301

296-
$(parent_el + ' #mark-all-' + countlyAuth.typeNames[j] + '-' + i).countlyCheckbox().set(true);
302+
$(parent_el + ' #mark-all-' + countlyAuth.typeNames[j1] + '-' + i0).countlyCheckbox().set(true);
297303

298304
for (var k = 0; k < countlyAuth.features.length; k++) {
299-
$(parent_el + ' #' + countlyAuth.types[j] + '-' + countlyAuth.features[k] + '-' + i).countlyCheckbox().set(true);
300-
if (countlyAuth.types[j] === "r" && countlyAuth.features[k] === 'core') {
301-
$(parent_el + ' #' + countlyAuth.types[j] + '-' + countlyAuth.features[k] + '-' + i).countlyCheckbox().setDisabled();
305+
$(parent_el + ' #' + countlyAuth.types[j1] + '-' + countlyAuth.features[k] + '-' + i0).countlyCheckbox().set(true);
306+
if (countlyAuth.types[j1] === "r" && countlyAuth.features[k] === 'core') {
307+
$(parent_el + ' #' + countlyAuth.types[j1] + '-' + countlyAuth.features[k] + '-' + i0).countlyCheckbox().setDisabled();
302308
}
303309
}
304310

305-
permission_sets[i][countlyAuth.types[j]].all = true;
306-
permission_sets[i][countlyAuth.types[j]].allowed = permission_object[countlyAuth.types[j]][user_apps[i][0]].allowed;
311+
permission_sets[i0][countlyAuth.types[j1]].all = true;
312+
permission_sets[i0][countlyAuth.types[j1]].allowed = permission_object[countlyAuth.types[j1]][user_apps[i0][0]].allowed;
307313
}
308314
else {
309-
for (var feature in permission_object[countlyAuth.types[j]][user_apps[i][0]].allowed) {
310-
permission_sets[i] = countlyAuth.giveFeaturePermission(countlyAuth.types[j], feature, permission_sets[i]);
311-
$(parent_el + ' #' + countlyAuth.types[j] + '-' + feature + '-' + i).countlyCheckbox().set(true);
312-
if (countlyAuth.types[j] === "r" && feature === 'core') {
313-
$(parent_el + ' #' + countlyAuth.types[j] + '-' + feature + '-' + i).countlyCheckbox().setDisabled();
315+
for (var feature in permission_object[countlyAuth.types[j1]][user_apps[i0][0]].allowed) {
316+
permission_sets[i0] = countlyAuth.giveFeaturePermission(countlyAuth.types[j1], feature, permission_sets[i0]);
317+
$(parent_el + ' #' + countlyAuth.types[j1] + '-' + feature + '-' + i0).countlyCheckbox().set(true);
318+
if (countlyAuth.types[j1] === "r" && feature === 'core') {
319+
$(parent_el + ' #' + countlyAuth.types[j1] + '-' + feature + '-' + i0).countlyCheckbox().setDisabled();
314320
}
315321
}
316322
}

frontend/express/public/javascripts/countly/countly.template.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ var AppRouter = Backbone.Router.extend({
13691369
if (countlyAuth.validateRead('core')) {
13701370
self.addSubMenu("management", {code: "longtasks", url: "#/manage/tasks", text: "sidebar.management.longtasks", priority: 10});
13711371
}
1372-
1372+
13731373
var jobsIconSvg = '<svg width="20px" height="16px" viewBox="0 0 12 10" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><title>list-24px 2</title><g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="list-24px-2" fill="#9f9f9f" fill-rule="nonzero"><g id="list-24px"><path d="M0,6 L2,6 L2,4 L0,4 L0,6 Z M0,10 L2,10 L2,8 L0,8 L0,10 Z M0,2 L2,2 L2,0 L0,0 L0,2 Z M3,6 L12,6 L12,4 L3,4 L3,6 Z M3,10 L12,10 L12,8 L3,8 L3,10 Z M3,0 L3,2 L12,2 L12,0 L3,0 Z" id="Shape"></path></g></g></g></svg>';
13741374
if (countlyAuth.validateRead('global_applications')) {
13751375
self.addMenu("management", {code: "applications", url: "#/manage/apps", text: "sidebar.management.applications", icon: '<div class="logo-icon ion-ios-albums"></div>', priority: 10});

0 commit comments

Comments
 (0)