Language fixes and server crash fixes.

This commit is contained in:
Ylian Saint-Hilaire 2019-12-30 11:31:57 -08:00
parent d42c54f32e
commit 118fe48713
6 changed files with 1744 additions and 1684 deletions

View File

@ -962,7 +962,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
}); });
} else { } else {
// Create a filter for device groups // Create a filter for device groups
if (obj.user.links == null) return; if ((obj.user == null) || (obj.user.links == null)) return;
// All events // All events
var exGroupFilter2 = [], filter = [], filter2 = user.subscriptions; var exGroupFilter2 = [], filter = [], filter2 = user.subscriptions;

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.4.6-r", "version": "0.4.6-t",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",

File diff suppressed because it is too large Load Diff

View File

@ -705,14 +705,13 @@
else if ((passRequirements != null) && (typeof passRequirements.reset == 'number')) { else if ((passRequirements != null) && (typeof passRequirements.reset == 'number')) {
var seconds = (userinfo.passchange) + (passRequirements.reset * 86400) - Math.floor(Date.now() / 1000); var seconds = (userinfo.passchange) + (passRequirements.reset * 86400) - Math.floor(Date.now() / 1000);
if (seconds < 0) { QH('p2nextPasswordUpdateTime', " - Reset on next login."); } if (seconds < 0) { QH('p2nextPasswordUpdateTime', " - Reset on next login."); }
else if (seconds < 3600) { QH('p2nextPasswordUpdateTime', format(" - Reset in {0} minute{1}.", Math.floor(seconds / 60), addLetterS(Math.floor(seconds / 60)))); } else if (seconds < 3600) { var secs = Math.floor(seconds / 60); QH('p2nextPasswordUpdateTime',format((secs == 1)?" - Reset in 1 minute.":" - Reset in {0} minutes.", secs)); }
else if (seconds < 86400) { QH('p2nextPasswordUpdateTime', format(" - Reset in {0} hour{1}.", Math.floor(seconds / 3600), addLetterS(Math.floor(seconds / 3600)))); } else if (seconds < 86400) { var hours = Math.floor(seconds / 3600); QH('p2nextPasswordUpdateTime', format((hours == 1) ? " - Reset in 1 hour." : " - Reset in {0} hours.", hours)); }
else { QH('p2nextPasswordUpdateTime', format(" - Reset in {0} day{1}."), Math.floor(seconds / 86400), addLetterS(Math.floor(seconds / 86400))); } else { var days = Math.floor(seconds / 86400); QH('p2nextPasswordUpdateTime', format((hours == 1) ? " - Reset in 1 day." : " - Reset in {0} days.", days)); }
} }
} }
} }
function addLetterS(x) { return (x > 1) ? 's' : ''; }
function setSessionActivity() { sessionActivity = Date.now(); } function setSessionActivity() { sessionActivity = Date.now(); }
function checkIdleSessionTimeout() { var delta = (Date.now() - sessionActivity); if (delta > serverinfo.timeout) { window.location.href = 'logout'; } } function checkIdleSessionTimeout() { var delta = (Date.now() - sessionActivity); if (delta > serverinfo.timeout) { window.location.href = 'logout'; } }

View File

@ -1627,24 +1627,23 @@
else if ((passRequirements != null) && (typeof passRequirements.reset == 'number')) { else if ((passRequirements != null) && (typeof passRequirements.reset == 'number')) {
var seconds = (userinfo.passchange) + (passRequirements.reset * 86400) - Math.floor(Date.now() / 1000); var seconds = (userinfo.passchange) + (passRequirements.reset * 86400) - Math.floor(Date.now() / 1000);
if (seconds < 0) { QH('p2nextPasswordUpdateTime', " - Reset on next login."); } if (seconds < 0) { QH('p2nextPasswordUpdateTime', " - Reset on next login."); }
else if (seconds < 3600) { QH('p2nextPasswordUpdateTime', format(" - Reset in {0} minute{1}.", Math.floor(seconds / 60), addLetterS(Math.floor(seconds / 60)))); } else if (seconds < 3600) { var secs = Math.floor(seconds / 60); QH('p2nextPasswordUpdateTime',format((secs == 1)?" - Reset in 1 minute.":" - Reset in {0} minutes.", secs)); }
else if (seconds < 86400) { QH('p2nextPasswordUpdateTime', format(" - Reset in {0} hour{1}.", Math.floor(seconds / 3600), addLetterS(Math.floor(seconds / 3600)))); } else if (seconds < 86400) { var hours = Math.floor(seconds / 3600); QH('p2nextPasswordUpdateTime', format((hours == 1) ? " - Reset in 1 hour." : " - Reset in {0} hours.", hours)); }
else { QH('p2nextPasswordUpdateTime', format(" - Reset in {0} day{1}."), Math.floor(seconds / 86400), addLetterS(Math.floor(seconds / 86400))); } else { var days = Math.floor(seconds / 86400); QH('p2nextPasswordUpdateTime', format((hours == 1) ? " - Reset in 1 day." : " - Reset in {0} days.", days)); }
} }
} }
} }
function addLetterS(x) { return (x > 1) ? 's' : ''; }
function setSessionActivity() { sessionActivity = Date.now(); QH('idleTimeoutNotify', ''); } function setSessionActivity() { sessionActivity = Date.now(); QH('idleTimeoutNotify', ''); }
function checkIdleSessionTimeout() { function checkIdleSessionTimeout() {
var delta = (Date.now() - sessionActivity); var delta = (Date.now() - sessionActivity);
if (delta > serverinfo.timeout) { window.location.href = 'logout'; } else { if (delta > serverinfo.timeout) { window.location.href = 'logout'; } else {
var ds = Math.round((serverinfo.timeout - delta) / 1000); var ds = Math.round((serverinfo.timeout - delta) / 1000);
if (ds <= 60) { if (ds <= 60) {
QH('idleTimeoutNotify', '<br />' + format("{0} second{1} until disconnect", ds, addLetterS(ds))); QH('idleTimeoutNotify', '<br />' + format((ds == 1)?"1 second until disconnect":"{0} seconds until disconnect", ds));
} else { } else {
ds = Math.round(ds / 60); ds = Math.round(ds / 60);
if (ds <= 5) { QH('idleTimeoutNotify', '<br />' + format("{0} minute{1} until disconnect", ds, addLetterS(ds))); } if (ds <= 5) { QH('idleTimeoutNotify', '<br />' + format((ds == 1)?"1 minute until disconnect":"{0} minutes until disconnect", ds)); }
} }
} }
} }
@ -2580,7 +2579,7 @@
url = 'http://' + servername + portStr + domainUrl + 'agentinvite?c=' + message.cookie; url = 'http://' + servername + portStr + domainUrl + 'agentinvite?c=' + message.cookie;
} }
Q('agentInvitationLink').href = url; Q('agentInvitationLink').href = url;
var t = format("{0} hour{1}", message.expire, addLetterS(message.expire)); var t = format((message.expire == 1)?"1 hour":"{0} hours", message.expire);
if (message.expire == 24) { t = "1 day"; } if (message.expire == 24) { t = "1 day"; }
if (message.expire == 168) { t = "1 week"; } if (message.expire == 168) { t = "1 week"; }
if (message.expire == 5040) { t = "1 month"; } if (message.expire == 5040) { t = "1 month"; }
@ -6806,7 +6805,7 @@
p13uploadFileContinue(1, files); p13uploadFileContinue(1, files);
} else { } else {
// Otherwise, prompt for confirmation // Otherwise, prompt for confirmation
setDialogMode(2, "Upload File", 3, p13uploadFileContinue, format("Upload will overwrite {0} file{1}. Continue?", overWriteCount, addLetterS(overWriteCount)), files); setDialogMode(2, "Upload File", 3, p13uploadFileContinue, format((overWriteCount == 1)?"Upload will overwrite 1 file. Continue?":"Upload will overwrite {0} files. Continue?", overWriteCount), files);
} }
} }
@ -7370,7 +7369,7 @@
function account_showDeleteAccount() { function account_showDeleteAccount() {
if (xxdialogMode) return false; if (xxdialogMode) return false;
var x = "To delete this account, type in the account password in both boxes below and hit ok." + '<br /><br />'; var x = "To delete this account, type in the account password in both boxes below and hit ok." + '<br /><br />';
x += '<form method=post><input type=hidden name=action value=deleteaccount /><input type=hidden name=authcookie value=" + authCookie + " /><table style=margin-left:80px><tr>'; x += '<form method=post><input type=hidden name=action value=deleteaccount /><input type=hidden name=authcookie value=' + authCookie + ' /><table style=margin-left:80px><tr>';
x += '<td align=right>' + "Password:" + '</td><td><input id=apassword1 type=password name=apassword1 autocomplete=off onchange=account_validateDeleteAccount() onkeyup=account_validateDeleteAccount() /></td>'; x += '<td align=right>' + "Password:" + '</td><td><input id=apassword1 type=password name=apassword1 autocomplete=off onchange=account_validateDeleteAccount() onkeyup=account_validateDeleteAccount() /></td>';
x += '</tr><tr><td align=right>' + "Password:" + '</td><td><input id=apassword2 type=password name=apassword2 autocomplete=off onchange=account_validateDeleteAccount() onkeyup=account_validateDeleteAccount() /></td>'; x += '</tr><tr><td align=right>' + "Password:" + '</td><td><input id=apassword2 type=password name=apassword2 autocomplete=off onchange=account_validateDeleteAccount() onkeyup=account_validateDeleteAccount() /></td>';
x += '</tr></table><br /><div style=padding:10px;margin-bottom:4px>'; x += '</tr></table><br /><div style=padding:10px;margin-bottom:4px>';
@ -8467,7 +8466,7 @@
p5PerformUpload(1, files); p5PerformUpload(1, files);
} else { } else {
// Otherwise, prompt for confirmation // Otherwise, prompt for confirmation
setDialogMode(2, "Upload File", 3, p5PerformUpload, format("Upload will overwrite {0} file{1}. Continue?", overWriteCount, addLetterS(overWriteCount)), files); setDialogMode(2, "Upload File", 3, p5PerformUpload, format((overWriteCount == 1)?"Upload will overwrite 1 file. Continue?":"Upload will overwrite {0} files. Continue?", overWriteCount), files);
} }
} }

View File

@ -4158,7 +4158,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
function render(req, res, filename, args) { function render(req, res, filename, args) {
if ((obj.parent.webViewsOverridePath == null) && (obj.renderPages != null)) { if ((obj.parent.webViewsOverridePath == null) && (obj.renderPages != null)) {
// If a user set a localization, use that // If a user set a localization, use that
if (req.session.userid) { if ((req.session != null) && (req.session.userid)) {
var user = obj.users[req.session.userid]; var user = obj.users[req.session.userid];
if ((user != null) && (user.lang != null)) { req.query.lang = user.lang; } if ((user != null) && (user.lang != null)) { req.query.lang = user.lang; }
}; };