Added User Web State control on config.json.

Ylian Saint-Hilaire committed Feb 27, 2020 at 18:05 UTC 152a942ccc68603b0854d338915b5c1646eff9e0
5 files changed +18 -19
meshcentral.js
+3 -3
@@ -541,7 +541,7 @@ function CreateMeshCentralServer(config, args) {
541
542 // Lower case all keys in the config file
543 try {
544 - require('./common.js').objKeysToLower(config2, ["ldapoptions"]);
544 + require('./common.js').objKeysToLower(config2, ['ldapoptions', 'defaultuserwebstate', 'forceduserwebstate']);
545 } catch (ex) {
546 console.log('CRITICAL ERROR: Unable to access the file \"./common.js\".\r\nCheck folder & file permissions.');
547 process.exit();
@@ -830,7 +830,7 @@ function CreateMeshCentralServer(config, args) {
830
831 // Lower case all keys in the config file
832 try {
833 - require('./common.js').objKeysToLower(config2, ['ldapoptions']);
833 + require('./common.js').objKeysToLower(config2, ['ldapoptions', 'defaultuserwebstate', 'forceduserwebstate']);
834 } catch (ex) {
835 console.log("CRITICAL ERROR: Unable to access the file \"./common.js\".\r\nCheck folder & file permissions.");
836 process.exit();
@@ -2266,7 +2266,7 @@ function getConfig(createSampleConfig) {
2266
2267 // Lower case all keys in the config file
2268 try {
2269 - require('./common.js').objKeysToLower(config, ["ldapoptions"]);
2269 + require('./common.js').objKeysToLower(config, ['ldapoptions', 'defaultuserwebstate', 'forceduserwebstate']);
2270 } catch (ex) {
2271 console.log('CRITICAL ERROR: Unable to access the file \"./common.js\".\r\nCheck folder & file permissions.');
2272 process.exit();
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.4.9-m",
3 + "version": "0.4.9-n",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",
translate/translate.json
+6 -15
@@ -3636,7 +3636,7 @@
3636 "pt": "Erro de chamada",
3637 "ru": "Ошибка вызова",
3638 "xloc": [
3639 - "default.handlebars->27->1480"
3639 + "default.handlebars->27->1477"
3640 ]
3641 },
3642 {
@@ -8824,10 +8824,7 @@
8824 },
8825 {
8826 "en": "Illegal invocation",
8827 - "nl": "Ongeldige aanroep",
8828 - "xloc": [
8829 - "default.handlebars->27->1478"
8830 - ]
8827 + "nl": "Ongeldige aanroep"
8828 },
8829 {
8830 "cs": "Kódovaní obrazu",
@@ -10393,7 +10390,7 @@
10390 "pt": "Menos",
10391 "ru": "Меньше",
10392 "xloc": [
10396 - "default.handlebars->27->1482"
10393 + "default.handlebars->27->1479"
10394 ]
10395 },
10396 {
@@ -12016,7 +12013,7 @@
12013 "pt": "Mais",
12014 "ru": "Еще",
12015 "xloc": [
12019 - "default.handlebars->27->1481"
12016 + "default.handlebars->27->1478"
12017 ]
12018 },
12019 {
@@ -20615,10 +20612,7 @@
20612 },
20613 {
20614 "en": "encoding",
20618 - "nl": "codering",
20619 - "xloc": [
20620 - "default.handlebars->27->1477"
20621 - ]
20615 + "nl": "codering"
20616 },
20617 {
20618 "cs": "eventslist.csv",
@@ -21001,10 +20995,7 @@
20995 },
20996 {
20997 "en": "undefined",
21004 - "nl": "onbepaald",
21005 - "xloc": [
21006 - "default.handlebars->27->1479"
21007 - ]
20998 + "nl": "onbepaald"
20999 },
21000 {
21001 "cs": "uživatel:",
views/default.handlebars
+1
@@ -1128,6 +1128,7 @@
1128 var webState = '{{{webstate}}}';
1129 if (webState != '') { webState = JSON.parse(decodeURIComponent(webState)); }
1130 for (var i in webState) { localStorage.setItem(i, webState[i]); }
1131 + if (webState.deviceView != null) { localStorage.setItem('_deviceView', webState.deviceView); }
1132 if (!webState.loctag) { try { delete localStorage.removeItem('loctag'); } catch (ex) { } }
1133
1134 var args, urlargs;
webserver.js
+7
@@ -1590,6 +1590,13 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
1590 parent.debug('web', 'handleRootRequestEx: success.');
1591 obj.db.Get('ws' + user._id, function (err, states) {
1592 var webstate = (states.length == 1) ? obj.filterUserWebState(states[0].state) : '';
1593 + if ((webstate == '') && (typeof domain.defaultuserwebstate == 'object')) { webstate = JSON.stringify(domain.defaultuserwebstate); } // User has no web state, use defaults.
1594 + if (typeof domain.forceduserwebstate == 'object') { // Forces initial user web state is present, use it.
1595 + var webstate2 = {};
1596 + try { if (webstate != '') { webstate2 = JSON.parse(webstate); } } catch (ex) { }
1597 + for (var i in domain.forceduserwebstate) { webstate2[i] = domain.forceduserwebstate[i]; }
1598 + webstate = JSON.stringify(webstate2);
1599 + }
1600 render(req, res, getRenderPage('default', req), getRenderArgs({ authCookie: authCookie, authRelayCookie: authRelayCookie, viewmode: viewmode, currentNode: currentNode, logoutControls: JSON.stringify(logoutcontrols), domain: domain.id, debuglevel: parent.debugLevel, serverDnsName: obj.getWebServerName(domain), serverRedirPort: args.redirport, serverPublicPort: httpsPort, noServerBackup: (args.noserverbackup == 1 ? 1 : 0), features: features, sessiontime: args.sessiontime, mpspass: args.mpspass, passRequirements: passRequirements, webcerthash: Buffer.from(obj.webCertificateFullHashs[domain.id], 'binary').toString('base64').replace(/\+/g, '@').replace(/\//g, '$'), footer: (domain.footer == null) ? '' : domain.footer, webstate: encodeURIComponent(webstate), pluginHandler: (parent.pluginHandler == null) ? 'null' : parent.pluginHandler.prepExports(), StartGeoLocation: StartGeoLocation, EndGeoLocation: EndGeoLocation, StartGeoLocationJS: StartGeoLocationJS, EndGeoLocationJS: EndGeoLocationJS }, domain));
1601 });
1602 } else {