Guest sharing fixes.

This commit is contained in:
Ylian Saint-Hilaire 2021-09-12 11:17:54 -07:00
parent ac6c4ba1bc
commit 902e71a96f
3 changed files with 18 additions and 3 deletions

View File

@ -4696,8 +4696,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
//var cookie = { a: 5, p: command.p, uid: user._id, gn: command.guestname, nid: node._id, cf: command.consent, pid: publicid };
var cookie = { a: 6, pid: publicid };
//if ((startTime != null) && (expireTime != null)) { command.start = cookie.start = startTime; command.expire = cookie.expire = expireTime; }
//if (command.viewOnly === true) { cookie.vo = 1; }
if ((startTime != null) && (expireTime != null)) { command.start = startTime; command.expire = cookie.e = expireTime; }
const inviteCookie = parent.parent.encodeCookie(cookie, parent.parent.invitationLinkEncryptionKey);
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; }

View File

@ -36,6 +36,8 @@
"sample-config-advanced.json"
],
"dependencies": {
"archiver": "^4.0.2",
"archiver-zip-encrypted": "^1.0.10",
"body-parser": "^1.19.0",
"cbor": "~5.2.0",
"compression": "^1.7.4",
@ -43,13 +45,23 @@
"express": "^4.17.0",
"express-handlebars": "^3.1.0",
"express-ws": "^4.0.0",
"image-size": "^1.0.0",
"ipcheck": "^0.1.0",
"loadavg-windows": "^1.1.1",
"minimist": "^1.2.0",
"mongodb": "^4.1.0",
"multiparty": "^4.2.1",
"nedb": "^1.8.0",
"node-forge": "^0.10.0",
"node-rdpjs-2": "^0.3.5",
"node-windows": "^1.0.0-beta.5",
"otplib": "^10.2.3",
"saslprep": "^1.0.3",
"ssh2": "^1.4.0",
"web-push": "^3.4.5",
"ws": "^5.2.3",
"yauzl": "^2.10.0"
"yauzl": "^2.10.0",
"yubikeyotp": "^0.2.0"
},
"repository": {
"type": "git",

View File

@ -3490,6 +3490,10 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
// This is the new style sharing cookie, just encodes the pointer to the sharing information in the database.
// Gives a much more compact URL.
if (typeof c.pid != 'string') { res.sendStatus(404); return; }
// Check the expired time, expire message.
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; }
obj.db.Get('deviceshare-' + c.pid, function (err, docs) {
if ((err != null) || (docs == null) || (docs.length != 1)) { res.sendStatus(404); return; }
const doc = docs[0];