Fixed previous login dialog.
This commit is contained in:
parent
fdfa9450c1
commit
bb8e6d6511
8
db.js
8
db.js
|
@ -1241,7 +1241,7 @@ module.exports.CreateDB = function (parent, func) {
|
||||||
obj.GetEventsWithLimit = function (ids, domain, limit, func) { obj.eventsfile.find({ domain: domain, ids: { $in: ids } }).project({ type: 0, _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }).limit(limit).toArray(func); };
|
obj.GetEventsWithLimit = function (ids, domain, limit, func) { obj.eventsfile.find({ domain: domain, ids: { $in: ids } }).project({ type: 0, _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }).limit(limit).toArray(func); };
|
||||||
obj.GetUserEvents = function (ids, domain, username, func) { obj.eventsfile.find({ domain: domain, $or: [{ ids: { $in: ids } }, { username: username }] }).project({ type: 0, _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }).toArray(func); };
|
obj.GetUserEvents = function (ids, domain, username, func) { obj.eventsfile.find({ domain: domain, $or: [{ ids: { $in: ids } }, { username: username }] }).project({ type: 0, _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }).toArray(func); };
|
||||||
obj.GetUserEventsWithLimit = function (ids, domain, username, limit, func) { obj.eventsfile.find({ domain: domain, $or: [{ ids: { $in: ids } }, { username: username }] }).project({ type: 0, _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }).limit(limit).toArray(func); };
|
obj.GetUserEventsWithLimit = function (ids, domain, username, limit, func) { obj.eventsfile.find({ domain: domain, $or: [{ ids: { $in: ids } }, { username: username }] }).project({ type: 0, _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }).limit(limit).toArray(func); };
|
||||||
obj.GetUserLoginEvents = function (domain, username, func) { obj.eventsfile.find({ domain: domain, action: { $in: ['authfail', 'login'] }, msgArgs: { $exists: true } }).project({ action: 1, time: 1, msgid: 1, msgArgs: 1 }).sort({ time: -1 }).toArray(func); };
|
obj.GetUserLoginEvents = function (domain, userid, func) { obj.eventsfile.find({ domain: domain, action: { $in: ['authfail', 'login'] }, userid: userid, msgArgs: { $exists: true } }).project({ action: 1, time: 1, msgid: 1, msgArgs: 1 }).sort({ time: -1 }).toArray(func); };
|
||||||
obj.GetNodeEventsWithLimit = function (nodeid, domain, limit, func) { obj.eventsfile.find({ domain: domain, nodeid: nodeid }).project({ type: 0, etype: 0, _id: 0, domain: 0, ids: 0, node: 0, nodeid: 0 }).sort({ time: -1 }).limit(limit).toArray(func); };
|
obj.GetNodeEventsWithLimit = function (nodeid, domain, limit, func) { obj.eventsfile.find({ domain: domain, nodeid: nodeid }).project({ type: 0, etype: 0, _id: 0, domain: 0, ids: 0, node: 0, nodeid: 0 }).sort({ time: -1 }).limit(limit).toArray(func); };
|
||||||
obj.GetNodeEventsSelfWithLimit = function (nodeid, domain, userid, limit, func) { obj.eventsfile.find({ domain: domain, nodeid: nodeid, userid: { $in: [userid, null] } }).project({ type: 0, etype: 0, _id: 0, domain: 0, ids: 0, node: 0, nodeid: 0 }).sort({ time: -1 }).limit(limit).toArray(func); };
|
obj.GetNodeEventsSelfWithLimit = function (nodeid, domain, userid, limit, func) { obj.eventsfile.find({ domain: domain, nodeid: nodeid, userid: { $in: [userid, null] } }).project({ type: 0, etype: 0, _id: 0, domain: 0, ids: 0, node: 0, nodeid: 0 }).sort({ time: -1 }).limit(limit).toArray(func); };
|
||||||
obj.RemoveAllEvents = function (domain) { obj.eventsfile.deleteMany({ domain: domain }, { multi: true }); };
|
obj.RemoveAllEvents = function (domain) { obj.eventsfile.deleteMany({ domain: domain }, { multi: true }); };
|
||||||
|
@ -1427,11 +1427,11 @@ module.exports.CreateDB = function (parent, func) {
|
||||||
obj.eventsfile.find({ domain: domain, $or: [{ ids: { $in: ids } }, { username: username }] }, { type: 0, _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }).limit(limit, func);
|
obj.eventsfile.find({ domain: domain, $or: [{ ids: { $in: ids } }, { username: username }] }, { type: 0, _id: 0, domain: 0, ids: 0, node: 0 }).sort({ time: -1 }).limit(limit, func);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
obj.GetUserLoginEvents = function (domain, username, func) {
|
obj.GetUserLoginEvents = function (domain, userid, func) {
|
||||||
if (obj.databaseType == 1) {
|
if (obj.databaseType == 1) {
|
||||||
obj.eventsfile.find({ domain: domain, action: { $in: ['authfail', 'login'] }, msgArgs: { $exists: true } }, { action: 1, time: 1, msgid: 1, msgArgs: 1 }).sort({ time: -1 }).exec(func);
|
obj.eventsfile.find({ domain: domain, action: { $in: ['authfail', 'login'] }, userid: userid, msgArgs: { $exists: true } }, { action: 1, time: 1, msgid: 1, msgArgs: 1 }).sort({ time: -1 }).exec(func);
|
||||||
} else {
|
} else {
|
||||||
obj.eventsfile.find({ domain: domain, action: { $in: ['authfail', 'login'] }, msgArgs: { $exists: true } }, { action: 1, time: 1, msgid: 1, msgArgs: 1 }).sort({ time: -1 }, func);
|
obj.eventsfile.find({ domain: domain, action: { $in: ['authfail', 'login'] }, userid: userid, msgArgs: { $exists: true } }, { action: 1, time: 1, msgid: 1, msgArgs: 1 }).sort({ time: -1 }, func);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
obj.GetNodeEventsWithLimit = function (nodeid, domain, limit, func) { if (obj.databaseType == 1) { obj.eventsfile.find({ domain: domain, nodeid: nodeid }, { type: 0, etype: 0, _id: 0, domain: 0, ids: 0, node: 0, nodeid: 0 }).sort({ time: -1 }).limit(limit).exec(func); } else { obj.eventsfile.find({ domain: domain, nodeid: nodeid }, { type: 0, etype: 0, _id: 0, domain: 0, ids: 0, node: 0, nodeid: 0 }).sort({ time: -1 }).limit(limit, func); } };
|
obj.GetNodeEventsWithLimit = function (nodeid, domain, limit, func) { if (obj.databaseType == 1) { obj.eventsfile.find({ domain: domain, nodeid: nodeid }, { type: 0, etype: 0, _id: 0, domain: 0, ids: 0, node: 0, nodeid: 0 }).sort({ time: -1 }).limit(limit).exec(func); } else { obj.eventsfile.find({ domain: domain, nodeid: nodeid }, { type: 0, etype: 0, _id: 0, domain: 0, ids: 0, node: 0, nodeid: 0 }).sort({ time: -1 }).limit(limit, func); } };
|
||||||
|
|
|
@ -564,12 +564,11 @@ function CreateDesktopMultiplexor(parent, domain, nodeid, func) {
|
||||||
|
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 3: // Tile, check dimentions and store
|
case 3: // Tile, check dimentions and store
|
||||||
if (data.length < 10) break;
|
if ((data.length < 10) || (obj.lastData == null)) break;
|
||||||
var x = data.readUInt16BE(4), y = data.readUInt16BE(6);
|
var x = data.readUInt16BE(4), y = data.readUInt16BE(6);
|
||||||
var dimensions = require('image-size')(data.slice(8));
|
var dimensions = require('image-size')(data.slice(8));
|
||||||
var sx = (x / 16), sy = (y / 16), sw = (dimensions.width / 16), sh = (dimensions.height / 16);
|
var sx = (x / 16), sy = (y / 16), sw = (dimensions.width / 16), sh = (dimensions.height / 16);
|
||||||
obj.counter++;
|
obj.counter++;
|
||||||
//console.log("Tile", x, y, dimensions.width, dimensions.height);
|
|
||||||
|
|
||||||
// Keep a reference to this image & how many tiles it covers
|
// Keep a reference to this image & how many tiles it covers
|
||||||
obj.images[obj.counter] = { next: null, prev: obj.lastData, data: jumboData };
|
obj.images[obj.counter] = { next: null, prev: obj.lastData, data: jumboData };
|
||||||
|
|
|
@ -5401,7 +5401,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||||
// Get previous logins for self
|
// Get previous logins for self
|
||||||
if (db.GetUserLoginEvents) {
|
if (db.GetUserLoginEvents) {
|
||||||
// New way
|
// New way
|
||||||
db.GetUserLoginEvents(domain.id, user._id.split('/')[2], function (err, docs) {
|
db.GetUserLoginEvents(domain.id, user._id, function (err, docs) {
|
||||||
if (err != null) return;
|
if (err != null) return;
|
||||||
var e = [];
|
var e = [];
|
||||||
for (var i in docs) { e.push({ t: docs[i].time, m: docs[i].msgid, a: docs[i].msgArgs }); }
|
for (var i in docs) { e.push({ t: docs[i].time, m: docs[i].msgid, a: docs[i].msgArgs }); }
|
||||||
|
@ -5410,10 +5410,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||||
} else {
|
} else {
|
||||||
// Old way
|
// Old way
|
||||||
db.GetUserEvents([user._id], domain.id, user._id.split('/')[2], function (err, docs) {
|
db.GetUserEvents([user._id], domain.id, user._id.split('/')[2], function (err, docs) {
|
||||||
console.log(docs);
|
|
||||||
if (err != null) return;
|
if (err != null) return;
|
||||||
var e = [];
|
var e = [];
|
||||||
for (var i in docs) { if ((docs[i].msgArgs) && ((docs[i].action == 'authfail') || (docs[i].action == 'login'))) { e.push({ t: docs[i].time, m: docs[i].msgid, a: docs[i].msgArgs }); } }
|
for (var i in docs) { if ((docs[i].msgArgs) && (docs[i].userid == command.userid) && ((docs[i].action == 'authfail') || (docs[i].action == 'login'))) { e.push({ t: docs[i].time, m: docs[i].msgid, a: docs[i].msgArgs }); } }
|
||||||
try { ws.send(JSON.stringify({ action: 'previousLogins', events: e })); } catch (ex) { }
|
try { ws.send(JSON.stringify({ action: 'previousLogins', events: e })); } catch (ex) { }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -5424,7 +5423,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||||
if ((obj.crossDomain === true) || (splitUser[1] === domain.id)) {
|
if ((obj.crossDomain === true) || (splitUser[1] === domain.id)) {
|
||||||
if (db.GetUserLoginEvents) {
|
if (db.GetUserLoginEvents) {
|
||||||
// New way
|
// New way
|
||||||
db.GetUserLoginEvents(splitUser[1], splitUser[2], function (err, docs) {
|
db.GetUserLoginEvents(splitUser[1], user._id, function (err, docs) {
|
||||||
if (err != null) return;
|
if (err != null) return;
|
||||||
var e = [];
|
var e = [];
|
||||||
for (var i in docs) { e.push({ t: docs[i].time, m: docs[i].msgid, a: docs[i].msgArgs }); }
|
for (var i in docs) { e.push({ t: docs[i].time, m: docs[i].msgid, a: docs[i].msgArgs }); }
|
||||||
|
@ -5435,7 +5434,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||||
db.GetUserEvents([command.userid], splitUser[1], splitUser[2], function (err, docs) {
|
db.GetUserEvents([command.userid], splitUser[1], splitUser[2], function (err, docs) {
|
||||||
if (err != null) return;
|
if (err != null) return;
|
||||||
var e = [];
|
var e = [];
|
||||||
for (var i in docs) { if ((docs[i].msgArgs) && ((docs[i].action == 'authfail') || (docs[i].action == 'login'))) { e.push({ t: docs[i].time, m: docs[i].msgid, a: docs[i].msgArgs }); } }
|
for (var i in docs) { if ((docs[i].msgArgs) && (docs[i].userid == command.userid) && ((docs[i].action == 'authfail') || (docs[i].action == 'login'))) { e.push({ t: docs[i].time, m: docs[i].msgid, a: docs[i].msgArgs }); } }
|
||||||
try { ws.send(JSON.stringify({ action: 'previousLogins', userid: command.userid, events: e })); } catch (ex) { }
|
try { ws.send(JSON.stringify({ action: 'previousLogins', userid: command.userid, events: e })); } catch (ex) { }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue