Skip to content

Commit b2e6d1a

Browse files
committed
Cleaning up checksum_salt on update, showing value on fetch.
(To prevent errors for instances with bady saved data, because of previous bugs on edit app form)
1 parent 0b03e0c commit b2e6d1a

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

api/parts/mgmt/apps.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ appsApi.getAppsDetails = function(params) {
8686
return false;
8787
}
8888
params.app = app;
89+
if (app.checksum_salt) {
90+
app.salt = app.salt || app.checksum_salt;
91+
}
8992
if (params.app.owner) {
9093
params.app.owner_id = params.app.owner;
9194
params.app.owner = common.db.ObjectID(params.app.owner + "");
@@ -330,7 +333,7 @@ appsApi.updateApp = function(params) {
330333
'required': false,
331334
'type': 'String'
332335
},
333-
'checksum_salt': {
336+
'salt': {
334337
'required': false,
335338
'type': 'String'
336339
},
@@ -370,14 +373,15 @@ appsApi.updateApp = function(params) {
370373
}
371374

372375
updatedApp.edited_at = Math.floor(((new Date()).getTime()) / 1000);
376+
delete updatedApp.checksum_salt;
373377

374378
common.db.collection('apps').findOne(common.db.ObjectID(params.qstring.args.app_id), function(err, appBefore) {
375379
if (err || !appBefore) {
376380
common.returnMessage(params, 404, 'App not found');
377381
}
378382
else {
379383
if (params.member && params.member.global_admin) {
380-
common.db.collection('apps').update({'_id': common.db.ObjectID(params.qstring.args.app_id)}, {$set: updatedApp}, function() {
384+
common.db.collection('apps').update({'_id': common.db.ObjectID(params.qstring.args.app_id)}, {$set: updatedApp, "$unset": {"checksum_salt": ""}}, function() {
381385
plugins.dispatch("/i/apps/update", {
382386
params: params,
383387
appId: params.qstring.args.app_id,
@@ -392,7 +396,7 @@ appsApi.updateApp = function(params) {
392396
}
393397
else {
394398
if (hasUpdateRight(FEATURE_NAME, params.qstring.args.app_id, params.member)) {
395-
common.db.collection('apps').update({'_id': common.db.ObjectID(params.qstring.args.app_id)}, {$set: updatedApp}, function() {
399+
common.db.collection('apps').update({'_id': common.db.ObjectID(params.qstring.args.app_id)}, {$set: updatedApp, "$unset": {"checksum_salt": ""}}, function() {
396400
plugins.dispatch("/i/apps/update", {
397401
params: params,
398402
appId: params.qstring.args.app_id,

frontend/express/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,9 @@ Promise.all([plugins.dbConnection(countlyConfig), plugins.dbConnection("countly_
10241024
userOfApps = apps;
10251025

10261026
for (let i = 0; i < apps.length; i++) {
1027+
if (apps[i].checksum_salt) {
1028+
apps[i].salt = apps[i].salt || apps[i].checksum_salt;
1029+
}
10271030
apps[i].type = apps[i].type || "mobile";
10281031
countlyGlobalApps[apps[i]._id] = apps[i];
10291032
countlyGlobalApps[apps[i]._id]._id = "" + apps[i]._id;

0 commit comments

Comments
 (0)