Fixed user consent with guest sharing, #3492

This commit is contained in:
Ylian Saint-Hilaire 2022-01-24 09:56:12 -08:00
parent 106c3ca461
commit 9d621f23c6
3 changed files with 9 additions and 2 deletions

View File

@ -22,6 +22,7 @@
<ItemGroup>
<Compile Include="agents\meshcmd.js" />
<Compile Include="agents\meshcmd.min.js" />
<Compile Include="agents\meshcore.js" />
<Compile Include="agents\meshcore.min.js" />
<Compile Include="agents\meshinstall-linux.js" />
<Compile Include="agents\modules_meshcmd\amt-apfclient.js" />

View File

@ -1657,7 +1657,14 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
}
case 'getUserImage': {
// Validate input
if (typeof command.userid != 'string') return;
if (typeof command.userid != 'string') {
// Send back the default image if required
if ((command.default) || (command.sentDefault)) {
try { command.image = 'data:image/png;base64,' + Buffer.from(parent.fs.readFileSync(parent.parent.path.join(__dirname, 'public', 'images', 'user-128.png')), 'binary').toString('base64'); } catch (ex) { }
obj.send(JSON.stringify(command));
}
return;
}
var useridsplit = command.userid.split('/');
if ((useridsplit.length != 3) || (useridsplit[1] != domain.id)) return;

View File

@ -1333,7 +1333,6 @@ function CreateMeshRelayEx2(parent, ws, req, domain, user, cookie) {
if (user != null) { rcookieData.ruserid = user._id; } else if (obj.nouser === true) { rcookieData.nouser = 1; }
const rcookie = parent.parent.encodeCookie(rcookieData, parent.parent.loginCookieEncryptionKey);
const command = { nodeid: node._id, action: 'msg', type: 'tunnel', value: '*/meshrelay.ashx?p=2&id=' + obj.id + '&rauth=' + rcookie + '&nodeid=' + node._id, soptions: {}, usage: 2, rights: cookie.r, guestname: cookie.gn, consent: cookie.cf, remoteaddr: cleanRemoteAddr(obj.req.clientIp) };
if (user != null) { command.userid = user._id; }
if (typeof domain.consentmessages == 'object') {
if (typeof domain.consentmessages.title == 'string') { command.soptions.consentTitle = domain.consentmessages.title; }
if (typeof domain.consentmessages.desktop == 'string') { command.soptions.consentMsgDesktop = domain.consentmessages.desktop; }