mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Database performance + mesh undelete.
This commit is contained in:
parent
93c06209b6
commit
a14522548f
8 changed files with 228 additions and 100 deletions
40
webserver.js
40
webserver.js
|
@ -193,7 +193,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||
// Fetch all meshes from the database, keep this in memory
|
||||
obj.db.GetAllType('mesh', function (err, docs) {
|
||||
obj.common.unEscapeAllLinksFieldName(docs);
|
||||
for (var i in docs) { obj.meshes[docs[i]._id] = docs[i]; }
|
||||
for (var i in docs) {obj.meshes[docs[i]._id] = docs[i]; } // Get all meshes, including deleted ones.
|
||||
|
||||
// We loaded the users and mesh state, start the server
|
||||
serverStart();
|
||||
|
@ -2275,24 +2275,26 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||
// Creates a login token using the user/pass that is passed in as URL arguments.
|
||||
// For example: https://localhost/createLoginToken.ashx?user=admin&pass=admin&a=3
|
||||
// It's not advised to use this to create login tokens since the URL is often logged and you got credentials in the URL.
|
||||
// However, people want it so here it is.
|
||||
obj.app.get(url + 'createLoginToken.ashx', function (req, res) {
|
||||
// A web socket session can be authenticated in many ways (Default user, session, user/pass and cookie). Check authentication here.
|
||||
if ((req.query.user != null) && (req.query.pass != null)) {
|
||||
// A user/pass is provided in URL arguments
|
||||
obj.authenticate(req.query.user, req.query.pass, getDomain(req), function (err, userid) {
|
||||
if ((err == null) && (obj.users[userid])) {
|
||||
// User is authenticated, create a token
|
||||
var x = { a: 3 }; for (var i in req.query) { if ((i != 'user') && (i != 'pass')) { x[i] = obj.common.toNumber(req.query[i]); } } x.u = userid;
|
||||
res.send(obj.parent.encodeCookie(x, obj.parent.loginCookieEncryptionKey));
|
||||
} else {
|
||||
res.sendStatus(404);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
res.sendStatus(404);
|
||||
}
|
||||
});
|
||||
// Since it's bad, it's only offered when an untrusted certificate is used as a way to help developers get started.
|
||||
if (isTrustedCert() == false) {
|
||||
obj.app.get(url + 'createLoginToken.ashx', function (req, res) {
|
||||
// A web socket session can be authenticated in many ways (Default user, session, user/pass and cookie). Check authentication here.
|
||||
if ((req.query.user != null) && (req.query.pass != null)) {
|
||||
// A user/pass is provided in URL arguments
|
||||
obj.authenticate(req.query.user, req.query.pass, getDomain(req), function (err, userid) {
|
||||
if ((err == null) && (obj.users[userid])) {
|
||||
// User is authenticated, create a token
|
||||
var x = { a: 3 }; for (var i in req.query) { if ((i != 'user') && (i != 'pass')) { x[i] = obj.common.toNumber(req.query[i]); } } x.u = userid;
|
||||
res.send(obj.parent.encodeCookie(x, obj.parent.loginCookieEncryptionKey));
|
||||
} else {
|
||||
res.sendStatus(404);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
res.sendStatus(404);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
obj.app.get(url + 'stop', function (req, res) { res.send('Stopping Server, <a href="' + url + '">click here to login</a>.'); setTimeout(function () { parent.Stop(); }, 500); });
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue