Guest sharing fixes.

Ylian Saint-Hilaire committed Sep 12, 2021 at 11:17 UTC 902e71a96f72ec563a23dc64070ed8546000c9d1
3 files changed +18 -3
meshuser.js
+1 -2
@@ -4696,8 +4696,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
4696
4697 //var cookie = { a: 5, p: command.p, uid: user._id, gn: command.guestname, nid: node._id, cf: command.consent, pid: publicid };
4698 var cookie = { a: 6, pid: publicid };
4699 - //if ((startTime != null) && (expireTime != null)) { command.start = cookie.start = startTime; command.expire = cookie.expire = expireTime; }
4700 - //if (command.viewOnly === true) { cookie.vo = 1; }
4699 + if ((startTime != null) && (expireTime != null)) { command.start = startTime; command.expire = cookie.e = expireTime; }
4700 const inviteCookie = parent.parent.encodeCookie(cookie, parent.parent.invitationLinkEncryptionKey);
4701 if (inviteCookie == null) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'createDeviceShareLink', responseid: command.responseid, result: 'Unable to generate shareing cookie' })); } catch (ex) { } } return; }
4702
package.json
+13 -1
@@ -36,6 +36,8 @@
36 "sample-config-advanced.json"
37 ],
38 "dependencies": {
39 + "archiver": "^4.0.2",
40 + "archiver-zip-encrypted": "^1.0.10",
41 "body-parser": "^1.19.0",
42 "cbor": "~5.2.0",
43 "compression": "^1.7.4",
@@ -43,13 +45,23 @@
45 "express": "^4.17.0",
46 "express-handlebars": "^3.1.0",
47 "express-ws": "^4.0.0",
48 + "image-size": "^1.0.0",
49 "ipcheck": "^0.1.0",
50 + "loadavg-windows": "^1.1.1",
51 "minimist": "^1.2.0",
52 + "mongodb": "^4.1.0",
53 "multiparty": "^4.2.1",
54 "nedb": "^1.8.0",
55 "node-forge": "^0.10.0",
56 + "node-rdpjs-2": "^0.3.5",
57 + "node-windows": "^1.0.0-beta.5",
58 + "otplib": "^10.2.3",
59 + "saslprep": "^1.0.3",
60 + "ssh2": "^1.4.0",
61 + "web-push": "^3.4.5",
62 "ws": "^5.2.3",
52 - "yauzl": "^2.10.0"
63 + "yauzl": "^2.10.0",
64 + "yubikeyotp": "^0.2.0"
65 },
66 "repository": {
67 "type": "git",
webserver.js
+4
@@ -3490,6 +3490,10 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
3490 // This is the new style sharing cookie, just encodes the pointer to the sharing information in the database.
3491 // Gives a much more compact URL.
3492 if (typeof c.pid != 'string') { res.sendStatus(404); return; }
3493 +
3494 + // Check the expired time, expire message.
3495 + if ((c.e != null) && (c.e <= Date.now())) { render(req, res, getRenderPage((domain.sitestyle == 2) ? 'message2' : 'message', req, domain), getRenderArgs({ titleid: 2, msgid: 12, domainurl: encodeURIComponent(domain.url).replace(/'/g, '%27') }, req, domain)); return; }
3496 +
3497 obj.db.Get('deviceshare-' + c.pid, function (err, docs) {
3498 if ((err != null) || (docs == null) || (docs.length != 1)) { res.sendStatus(404); return; }
3499 const doc = docs[0];