Improved event internalization

This commit is contained in:
Ylian Saint-Hilaire 2020-09-09 01:32:00 -07:00
parent 2c2539b431
commit 260d145095
24 changed files with 4689 additions and 630 deletions

View File

@ -1,15 +1,15 @@
<html><head></head><body><div>[[[SERVERNAME]]] - Email Verification</div> <html><head></head><body><div>[[[SERVERNAME]]] - Verificação de Email</div>
<div style="font-family:Arial,Helvetica,sans-serif"> <div style="font-family:Arial,Helvetica,sans-serif">
<table style="background-color:#003366;color:lightgray;width:100%" cellpadding="8"> <table style="background-color:#003366;color:lightgray;width:100%" cellpadding="8">
<tbody><tr> <tbody><tr>
<td> <td>
<b style="font-size:20px;font-family:Arial,Helvetica,sans-serif">[[[SERVERNAME]]] - Verification</b> <b style="font-size:20px;font-family:Arial,Helvetica,sans-serif">[[[SERVERNAME]]] - Verificação</b>
</td> </td>
</tr> </tr>
</tbody></table> </tbody></table>
<p>Hi [[[USERNAME]]], <a href="[[[SERVERURL]]]">[[[SERVERNAME]]]</a> is requesting email verification, click on the following link to complete the process.</p> <p>Olá [[[NOME DE USUÁRIO]]], <a href="[[[SERVERURL]]]">[[[SERVERNAME]]]</a> está solicitando verificação de e-mail, clique no link a seguir para concluir o processo.</p>
<p style="margin-left:30px"> <p style="margin-left:30px">
<a href="[[[SERVERURL]]]/checkmail?c=[[[COOKIE]]]">Click here to verify your e-mail address.</a> <a href="[[[SERVERURL]]]/checkmail?c=[[[COOKIE]]]">Clique aqui para verificar seu endereço de e-mail.</a>
</p> </p>
If you did not initiate this request, please ignore this mail. Se você não iniciou esta solicitação, ignore este e-mail.
</div></body></html> </div></body></html>

View File

@ -1,6 +1,6 @@
[[[SERVERNAME]]] - Email Verification [[[SERVERNAME]]] - Verificação de Email
Hi [[[USERNAME]]], [[[SERVERNAME]]] ([[[SERVERURL]]]) is performing an e-mail verification. Nagivate to the following link to complete the process: Olá, [[[USERNAME]]], [[[SERVERNAME]]] ([[[SERVERURL]]]) está realizando uma verificação de e-mail. Acesse o seguinte link para concluir o processo:
~ ~
~[[[SERVERURL]]]/checkmail?c=[[[COOKIE]]] ~[[[SERVERURL]]]/checkmail?c=[[[COOKIE]]]
~ ~
If you did not initiate this request, please ignore this mail. Se você não iniciou esta solicitação, ignore este e-mail.

View File

@ -1,5 +1,5 @@
[[[SERVERNAME]]] - Pozvánka na účet [[[SERVERNAME]]] - Pozvánka na účet
An account was created for you on server [[[SERVERNAME]]] ([[[SERVERURL]]]/), you can access it now with username "[[[ACCOUNTNAME]]]" and password "[[[PASSWORD]]]". Účet pro vás byl vytvořen na serveru [[[SERVERNAME]]] ([[[[SERVERURL]]] /), nyní k němu můžete přistupovat pomocí uživatelského jména „[[[[ACCOUNTNAME]]]“ “a hesla„ [[[HESLO]] ]] ".
~ ~
S pozdravem, S pozdravem,
~[[[USERNAME]]] ~[[[USERNAME]]]

View File

@ -1,19 +1,19 @@
<html><head></head><body><div>[[[SERVERNAME]]] - Account Invitation</div> <html><head></head><body><div>[[[SERVERNAME]]] - Convite para conta</div>
<div style="font-family:Arial,Helvetica,sans-serif"> <div style="font-family:Arial,Helvetica,sans-serif">
<table style="background-color:#003366;color:lightgray;width:100%" cellpadding="8"> <table style="background-color:#003366;color:lightgray;width:100%" cellpadding="8">
<tbody><tr> <tbody><tr>
<td> <td>
<b style="font-size:20px;font-family:Arial,Helvetica,sans-serif">[[[SERVERNAME]]] - Account Invitation</b> <b style="font-size:20px;font-family:Arial,Helvetica,sans-serif">[[[SERVERNAME]]] - Convite para conta</b>
</td> </td>
</tr> </tr>
</tbody></table> </tbody></table>
<p>An account was created for you on server <a href="[[[SERVERURL]]]" notrans="1">[[[SERVERNAME]]]</a>, you can access it now with:</p> <p>Uma conta foi criada para você no servidor <a href="[[[SERVERURL]]]" notrans="1">[[[SERVERNAME]]]</a>, você pode acessá-lo agora com:</p>
<p> <p>
&nbsp;&nbsp;&nbsp;Nome de usuário: <b notrans="1">[[[ACCOUNTNAME]]]</b><br> &nbsp;&nbsp;&nbsp;Nome de usuário: <b notrans="1">[[[ACCOUNTNAME]]]</b><br>
&nbsp;&nbsp;&nbsp;Senha: <b notrans="1">[[[PASSWORD]]]</b> &nbsp;&nbsp;&nbsp;Senha: <b notrans="1">[[[PASSWORD]]]</b>
</p> </p>
Best regards, Cumprimentos,
<br> <br>
[[[USERNAME]]] [[[NOME DO USUÁRIO]]]
<br> <br>
</div></body></html> </div></body></html>

View File

@ -1,5 +1,5 @@
[[[SERVERNAME]]] - Account Invitation [[[SERVERNAME]]] - Convite para conta
An account was created for you on server [[[SERVERNAME]]] ([[[SERVERURL]]]/), you can access it now with username "[[[ACCOUNTNAME]]]" and password "[[[PASSWORD]]]". Uma conta foi criada para você no servidor [[[SERVERNAME]]] ([[[SERVERURL]]] /), você pode acessá-la agora com o nome de usuário "[[[ACCOUNTNAME]]]" e a senha "[[[PASSWORD] ]] ".
~ ~
Best regards, Cumprimentos,
~[[[USERNAME]]] ~[[[USERNAME]]]

View File

@ -1,5 +1,5 @@
[[[SERVERNAME]]] - приглашение в аккаунт [[[SERVERNAME]]] - приглашение в аккаунт
An account was created for you on server [[[SERVERNAME]]] ([[[SERVERURL]]]/), you can access it now with username "[[[ACCOUNTNAME]]]" and password "[[[PASSWORD]]]". Учетная запись была создана для вас на сервере [[[SERVERNAME]]] ([[[SERVERURL]]] /), теперь вы можете получить к ней доступ с именем пользователя «[[[ACCOUNTNAME]]]» и паролем «[[[PASSWORD] ]] ".
~ ~
С уважением, С уважением,
~[[[USERNAME]]] ~[[[USERNAME]]]

View File

@ -7,6 +7,6 @@
</td> </td>
</tr> </tr>
</tbody></table> </tbody></table>
<p>Your login token is: [[[TOKEN]]]</p> <p>Kirjautumistunnuksesi on: [[[TOKEN]]]</p>
<p>This token can only be used once and is valid for 5 minutes.</p> <p>Tätä tunnusta voidaan käyttää vain kerran ja se on voimassa 5 minuuttia.</p>
</div></body></html> </div></body></html>

View File

@ -1,4 +1,4 @@
[[[SERVERNAME]]] - Tilille Kirjautuminen [[[SERVERNAME]]] - Tilille Kirjautuminen
Your login token is: [[[TOKEN]]] Kirjautumistunnuksesi on: [[[TOKEN]]]
~ ~
This token can only be used once and is valid for 5 minutes. Tätä tunnusta voidaan käyttää vain kerran ja se on voimassa 5 minuuttia.

View File

@ -1,12 +1,12 @@
<html><head></head><body><div>[[[SERVERNAME]]] - Account Login</div> <html><head></head><body><div>[[[SERVERNAME]]] - Login da conta</div>
<div style="font-family:Arial,Helvetica,sans-serif"> <div style="font-family:Arial,Helvetica,sans-serif">
<table style="background-color:#003366;color:lightgray;width:100%" cellpadding="8"> <table style="background-color:#003366;color:lightgray;width:100%" cellpadding="8">
<tbody><tr> <tbody><tr>
<td> <td>
<b style="font-size:20px;font-family:Arial,Helvetica,sans-serif">[[[SERVERNAME]]] - Account Login</b> <b style="font-size:20px;font-family:Arial,Helvetica,sans-serif">[[[SERVERNAME]]] - Login da conta</b>
</td> </td>
</tr> </tr>
</tbody></table> </tbody></table>
<p>Your login token is: [[[TOKEN]]]</p> <p>Seu token de login é: [[[TOKEN]]]</p>
<p>This token can only be used once and is valid for 5 minutes.</p> <p>Este token só pode ser usado uma vez e é válido por 5 minutos.</p>
</div></body></html> </div></body></html>

View File

@ -1,4 +1,4 @@
[[[SERVERNAME]]] - Account Login [[[SERVERNAME]]] - Login da conta
Your login token is: [[[TOKEN]]] Seu token de login é: [[[TOKEN]]]
~ ~
This token can only be used once and is valid for 5 minutes. Este token só pode ser usado uma vez e é válido por 5 minutos.

View File

@ -1,15 +1,15 @@
<html><head></head><body><div>[[[SERVERNAME]]] - Account Reset</div> <html><head></head><body><div>[[[SERVERNAME]]] - Redefinição de conta</div>
<div style="font-family:Arial,Helvetica,sans-serif"> <div style="font-family:Arial,Helvetica,sans-serif">
<table style="background-color:#003366;color:lightgray;width:100%" cellpadding="8"> <table style="background-color:#003366;color:lightgray;width:100%" cellpadding="8">
<tbody><tr> <tbody><tr>
<td> <td>
<b style="font-size:20px;font-family:Arial,Helvetica,sans-serif">[[[SERVERNAME]]] - Verification</b> <b style="font-size:20px;font-family:Arial,Helvetica,sans-serif">[[[SERVERNAME]]] - Verificação</b>
</td> </td>
</tr> </tr>
</tbody></table> </tbody></table>
<p>Hi [[[USERNAME]]], <a href="[[[SERVERURL]]]">[[[SERVERNAME]]]</a> is requesting an account password reset, click on the following link to complete the process.</p> <p>Olá [[[NOME DE USUÁRIO]]], <a href="[[[SERVERURL]]]">[[[SERVERNAME]]]</a> está solicitando a redefinição da senha da conta, clique no link a seguir para concluir o processo.</p>
<p style="margin-left:30px"> <p style="margin-left:30px">
<a href="[[[SERVERURL]]]/checkmail?c=[[[COOKIE]]]">Click here to reset your account password.</a> <a href="[[[SERVERURL]]]/checkmail?c=[[[COOKIE]]]">Clique aqui para redefinir a senha da sua conta.</a>
</p> </p>
If you did not initiate this request, please ignore this mail. Se você não iniciou esta solicitação, ignore este e-mail.
</div></body></html> </div></body></html>

View File

@ -1,6 +1,6 @@
[[[SERVERNAME]]] - Account Reset [[[SERVERNAME]]] - Redefinição de conta
Hi [[[USERNAME]]], [[[SERVERNAME]]] ([[[SERVERURL]]]) is requesting an account password reset. Nagivate to the following link to complete the process: Olá, [[[USERNAME]]], [[[SERVERNAME]]] ([[[SERVERURL]]]) está solicitando uma redefinição de senha de conta. Acesse o seguinte link para concluir o processo:
~ ~
~[[[SERVERURL]]]/checkmail?c=[[[COOKIE]]] ~[[[SERVERURL]]]/checkmail?c=[[[COOKIE]]]
~ ~
If you did not initiate this request, please ignore this mail. Se você não iniciou esta solicitação, ignore este e-mail.

View File

@ -28,7 +28,7 @@
</area-osx> </area-osx>
<area-linux> <area-linux>
<p> <p>
For Linux, cut &amp; paste the following in a terminal to install the agent:<br> Linux: leikkaa ja liitä seuraava päätelaitteeseen agentin asentamiseksi:<br>
</p><pre style="margin-left:30px" notrans="1">wget -q "[[[SERVERURL]]]/meshagents?script=1" --no-check-certificate -O ./meshinstall.sh &amp;&amp; chmod 755 ./meshinstall.sh &amp;&amp; sudo ./meshinstall.sh [[[SERVERURL]]] \'[[[MESHIDHEX]]]\'</pre> </p><pre style="margin-left:30px" notrans="1">wget -q "[[[SERVERURL]]]/meshagents?script=1" --no-check-certificate -O ./meshinstall.sh &amp;&amp; chmod 755 ./meshinstall.sh &amp;&amp; sudo ./meshinstall.sh [[[SERVERURL]]] \'[[[MESHIDHEX]]]\'</pre>
<p></p> <p></p>
</area-linux> </area-linux>

View File

@ -9,25 +9,25 @@ Viesti: [[[MSG]]]
~ ~
~</area-msg> ~</area-msg>
~<area-windows> ~<area-windows>
For Windows, nagivate to the following link to complete the process: Jos kyseessä on Windows, suorita prosessi loppuun avaamalla seuraava linkki:
~ ~
~[[[SERVERURL]]]/meshagents?id=3&meshid=[[[MESHIDHEX]]]&tag=mailto:[[[EMAIL]]]&installflags=[[[INSTALLFLAGS]]] ~[[[SERVERURL]]]/meshagents?id=3&meshid=[[[MESHIDHEX]]]&tag=mailto:[[[EMAIL]]]&installflags=[[[INSTALLFLAGS]]]
~ ~
~</area-windows> ~</area-windows>
~<area-osx> ~<area-osx>
For Apple OSX, nagivate to the following link to complete the process: Apple OSX -käyttöjärjestelmässä prosessin loppuun saattamiseksi napsauta seuraavaa linkkiä:
~ ~
~[[[SERVERURL]]]/meshagents?id=16&meshid=[[[MESHIDHEX]]]&tag=mailto:[[[EMAIL]]]&installflags=[[[INSTALLFLAGS]]] ~[[[SERVERURL]]]/meshagents?id=16&meshid=[[[MESHIDHEX]]]&tag=mailto:[[[EMAIL]]]&installflags=[[[INSTALLFLAGS]]]
~ ~
~</area-osx> ~</area-osx>
~<area-linux> ~<area-linux>
For Linux, cut & paste the following in a terminal to install the agent: Linux: leikkaa ja liitä seuraava päätelaitteeseen agentin asentamiseksi:
~ ~
~wget -q "[[[SERVERURL]]]/meshagents?script=1" --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh [[[SERVERURL]]] '[[[MESHIDHEX]]]' ~wget -q "[[[SERVERURL]]]/meshagents?script=1" --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh [[[SERVERURL]]] '[[[MESHIDHEX]]]'
~ ~
~</area-linux> ~</area-linux>
~<area-link> ~<area-link>
To install the software, navigate to [[[SERVERURL]]][[[LINKURL]]] and follow the instructions. Asenna ohjelmisto siirtymällä kohtaan [[[SERVERURL]]] [[[[LINKURL]]] ja noudattamalla ohjeita.
~</area-link> ~</area-link>
Jos et suorittanut tätä pyyntöä, voit ohitaa tämän sähköpostin. Jos et suorittanut tätä pyyntöä, voit ohitaa tämän sähköpostin.
~ ~

View File

@ -1,42 +1,42 @@
<html><head></head><body><div>[[[SERVERNAME]]] - Invitation</div> <html><head></head><body><div>[[[SERVERNAME]]] - Convite</div>
<div style="font-family:Arial,Helvetica,sans-serif"> <div style="font-family:Arial,Helvetica,sans-serif">
<table style="background-color:#003366;color:lightgray;width:100%" cellpadding="8"> <table style="background-color:#003366;color:lightgray;width:100%" cellpadding="8">
<tbody><tr> <tbody><tr>
<td> <td>
<b style="font-size:20px;font-family:Arial,Helvetica,sans-serif">[[[SERVERNAME]]] - Agent Installation</b> <b style="font-size:20px;font-family:Arial,Helvetica,sans-serif">[[[SERVERNAME]]] - Instalação do Agente</b>
</td> </td>
</tr> </tr>
</tbody></table> </tbody></table>
<area-name> <area-name>
<p> <p>
Hello [[[NAME]]], Olá [[[NAME]]],
</p> </p>
</area-name> </area-name>
<p>User [[[USERNAME]]] on server <a href="[[[SERVERURL]]]">[[[SERVERNAME]]]</a> is requesting you to install software to start a remote control session.</p> <p>Usuário [[[USERNAME]]] no servidor <a href="[[[SERVERURL]]]">[[[SERVERNAME]]]</a> está solicitando a instalação de um software para iniciar uma sessão de controle remoto.</p>
<area-msg> <area-msg>
<p> <p>
Message: <b notrans="1">[[[MSG]]]</b> Mensagem: <b notrans="1">[[[MSG]]]</b>
</p> </p>
</area-msg> </area-msg>
<area-windows> <area-windows>
<p style="margin-left:30px"> <p style="margin-left:30px">
<a href="[[[SERVERURL]]]/meshagents?id=3&amp;meshid=[[[MESHIDHEX]]]&amp;tag=mailto:[[[EMAIL]]]&amp;installflags=[[[INSTALLFLAGS]]]">Click here to download the MeshAgent for Windows.</a> <a href="[[[SERVERURL]]]/meshagents?id=3&amp;meshid=[[[MESHIDHEX]]]&amp;tag=mailto:[[[EMAIL]]]&amp;installflags=[[[INSTALLFLAGS]]]">Clique aqui para baixar o MeshAgent para Windows.</a>
</p> </p>
</area-windows> </area-windows>
<area-osx> <area-osx>
<p style="margin-left:30px"><a href="[[[SERVERURL]]]/meshagents?id=16&amp;meshid=[[[MESHIDHEX]]]&amp;tag=mailto:[[[EMAIL]]]&amp;installflags=[[[INSTALLFLAGS]]]">Click here to download the MeshAgent for Apple OSX.</a></p> <p style="margin-left:30px"><a href="[[[SERVERURL]]]/meshagents?id=16&amp;meshid=[[[MESHIDHEX]]]&amp;tag=mailto:[[[EMAIL]]]&amp;installflags=[[[INSTALLFLAGS]]]">Clique aqui para baixar o MeshAgent para Apple OSX.</a></p>
</area-osx> </area-osx>
<area-linux> <area-linux>
<p> <p>
For Linux, cut &amp; paste the following in a terminal to install the agent:<br> Para Linux, recorte e cole o seguinte em um terminal para instalar o agente:<br>
</p><pre style="margin-left:30px" notrans="1">wget -q "[[[SERVERURL]]]/meshagents?script=1" --no-check-certificate -O ./meshinstall.sh &amp;&amp; chmod 755 ./meshinstall.sh &amp;&amp; sudo ./meshinstall.sh [[[SERVERURL]]] \'[[[MESHIDHEX]]]\'</pre> </p><pre style="margin-left:30px" notrans="1">wget -q "[[[SERVERURL]]]/meshagents?script=1" --no-check-certificate -O ./meshinstall.sh &amp;&amp; chmod 755 ./meshinstall.sh &amp;&amp; sudo ./meshinstall.sh [[[SERVERURL]]] \'[[[MESHIDHEX]]]\'</pre>
<p></p> <p></p>
</area-linux> </area-linux>
<area-link> <area-link>
<p> <p>
To install the software, <a href="[[[SERVERURL]]][[[LINKURL]]]">click here</a> and follow the instructions. Para instalar o software, <a href="[[[SERVERURL]]][[[LINKURL]]]">Clique aqui</a> e siga as instruções.
</p> </p>
</area-link> </area-link>
<p>If you did not initiate this request, please ignore this mail.</p> <p>Se você não iniciou esta solicitação, ignore este e-mail.</p>
Best regards,<br>[[[USERNAME]]]<br> Cumprimentos,<br>[[[NOME DO USUÁRIO]]]<br>
</div></body></html> </div></body></html>

View File

@ -1,35 +1,35 @@
[[[SERVERNAME]]] - Invitation [[[SERVERNAME]]] - Convite
~<area-name> ~<area-name>
Hello [[[NAME]]], Olá [[[NAME]]],
~</area-name> ~</area-name>
User [[[USERNAME]]] on server [[[SERVERNAME]]] ([[[SERVERURL]]]/) is requesting you install software to start the remote control session. O usuário [[[USERNAME]]] no servidor [[[SERVERNAME]]] ([[[SERVERURL]]] /) está solicitando a instalação do software para iniciar a sessão de controle remoto.
~<area-msg> ~<area-msg>
~ ~
Message: [[[MSG]]] Mensagem: [[[MSG]]]
~ ~
~</area-msg> ~</area-msg>
~<area-windows> ~<area-windows>
For Windows, nagivate to the following link to complete the process: Para Windows, vá ao seguinte link para concluir o processo:
~ ~
~[[[SERVERURL]]]/meshagents?id=3&meshid=[[[MESHIDHEX]]]&tag=mailto:[[[EMAIL]]]&installflags=[[[INSTALLFLAGS]]] ~[[[SERVERURL]]]/meshagents?id=3&meshid=[[[MESHIDHEX]]]&tag=mailto:[[[EMAIL]]]&installflags=[[[INSTALLFLAGS]]]
~ ~
~</area-windows> ~</area-windows>
~<area-osx> ~<area-osx>
For Apple OSX, nagivate to the following link to complete the process: Para Apple OSX, vá ao seguinte link para concluir o processo:
~ ~
~[[[SERVERURL]]]/meshagents?id=16&meshid=[[[MESHIDHEX]]]&tag=mailto:[[[EMAIL]]]&installflags=[[[INSTALLFLAGS]]] ~[[[SERVERURL]]]/meshagents?id=16&meshid=[[[MESHIDHEX]]]&tag=mailto:[[[EMAIL]]]&installflags=[[[INSTALLFLAGS]]]
~ ~
~</area-osx> ~</area-osx>
~<area-linux> ~<area-linux>
For Linux, cut & paste the following in a terminal to install the agent: Para Linux, recorte e cole o seguinte em um terminal para instalar o agente:
~ ~
~wget -q "[[[SERVERURL]]]/meshagents?script=1" --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh [[[SERVERURL]]] '[[[MESHIDHEX]]]' ~wget -q "[[[SERVERURL]]]/meshagents?script=1" --no-check-certificate -O ./meshinstall.sh && chmod 755 ./meshinstall.sh && sudo ./meshinstall.sh [[[SERVERURL]]] '[[[MESHIDHEX]]]'
~ ~
~</area-linux> ~</area-linux>
~<area-link> ~<area-link>
To install the software, navigate to [[[SERVERURL]]][[[LINKURL]]] and follow the instructions. Para instalar o software, navegue até [[[SERVERURL]]] [[[LINKURL]]] e siga as instruções.
~</area-link> ~</area-link>
If you did not initiate this request, please ignore this mail. Se você não iniciou esta solicitação, ignore este e-mail.
~ ~
Best regards, Cumprimentos,
~[[[USERNAME]]] ~[[[USERNAME]]]

View File

@ -1,2 +1,2 @@
[[0]] verification code is: [[1]] [[0]] ověřovací kód je: [[1]]
[[0]] access token is: [[1]] [[0]] přístupový token je: [[1]]

View File

@ -1,2 +1,2 @@
[[0]] verification code is: [[1]] [[0]] Bestätigungscode lautet: [[1]]
[[0]] access token is: [[1]] [[0]] Zugriffstoken ist: [[1]]

View File

@ -1,2 +1,2 @@
[[0]] verification code is: [[1]] [[0]] código de verificação é: [[1]]
[[0]] access token is: [[1]] [[0]] token de acesso é: [[1]]

View File

@ -1,2 +1,2 @@
[[0]] verification code is: [[1]] [[0]] код подтверждения: [[1]]
[[0]] access token is: [[1]] [[0]] токен доступа: [[1]]

View File

@ -1583,8 +1583,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (mesh.links[deluser._id] != null) { delete mesh.links[deluser._id]; parent.db.Set(mesh); } if (mesh.links[deluser._id] != null) { delete mesh.links[deluser._id]; parent.db.Set(mesh); }
// Notify mesh change // Notify mesh change
change = 'Removed user ' + deluser.name + ' from group ' + mesh.name; change = 'Removed user ' + deluser.name + ' from device group ' + mesh.name;
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: change, domain: deluserdomain.id, invite: mesh.invite }; var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msgid: 72, msgArgs: [deluser.name, mesh.name], msg: change, domain: deluserdomain.id, invite: mesh.invite };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(mesh, [deluser._id, user._id]), obj, event); parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(mesh, [deluser._id, user._id]), obj, event);
} }
@ -1755,9 +1755,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var event, targets = ['*', 'server-users']; var event, targets = ['*', 'server-users'];
if (newuser.groups) { for (var i in newuser.groups) { targets.push('server-users:' + i); } } if (newuser.groups) { for (var i in newuser.groups) { targets.push('server-users:' + i); } }
if (newuser.email == null) { if (newuser.email == null) {
event = { etype: 'user', userid: newuser._id, username: newuser.name, account: parent.CloneSafeUser(newuser), action: 'accountcreate', msg: 'Account created, username is ' + newuser.name, domain: domain.id }; event = { etype: 'user', userid: newuser._id, username: newuser.name, account: parent.CloneSafeUser(newuser), action: 'accountcreate', msgid: 64, msgArgs: [newuser.name], msg: 'Account created, username is ' + newuser.name, domain: domain.id };
} else { } else {
event = { etype: 'user', userid: newuser._id, username: newuser.name, account: parent.CloneSafeUser(newuser), action: 'accountcreate', msg: 'Account created, email is ' + newuser.email, domain: domain.id }; event = { etype: 'user', userid: newuser._id, username: newuser.name, account: parent.CloneSafeUser(newuser), action: 'accountcreate', msgid: 65, msgArgs: [newuser.email], msg: 'Account created, email is ' + newuser.email, domain: domain.id };
} }
if (parent.db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to create the user. Another event will come. if (parent.db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to create the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
@ -1859,7 +1859,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
db.Set(ugroup); db.Set(ugroup);
// Notify user group change // Notify user group change
var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: ugroup._id, name: ugroup.name, desc: ugroup.desc, action: 'usergroupchange', links: ugroup.links, msg: 'Added user ' + newuser.name + ' to user group ' + ugroup.name, addUserDomain: newuserdomain.id }; var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: ugroup._id, name: ugroup.name, desc: ugroup.desc, action: 'usergroupchange', links: ugroup.links, msgid: 80, msgArgs: [newuser.name, ugroup.name], msg: 'Added user ' + newuser.name + ' to user group ' + ugroup.name, addUserDomain: newuserdomain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user group. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user group. Another event will come.
parent.parent.DispatchEvent(['*', ugroup._id, user._id, newuser._id], obj, event); parent.parent.DispatchEvent(['*', ugroup._id, user._id, newuser._id], obj, event);
} }
@ -1878,9 +1878,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var event, targets = ['*', 'server-users']; var event, targets = ['*', 'server-users'];
if (newuser.groups) { for (var i in newuser.groups) { targets.push('server-users:' + i); } } if (newuser.groups) { for (var i in newuser.groups) { targets.push('server-users:' + i); } }
if (command.email == null) { if (command.email == null) {
event = { etype: 'user', userid: newuser._id, username: newusername, account: parent.CloneSafeUser(newuser), action: 'accountcreate', msg: 'Account created, username is ' + command.username, domain: newuserdomain.id }; event = { etype: 'user', userid: newuser._id, username: newusername, account: parent.CloneSafeUser(newuser), action: 'accountcreate', msgid: 64, msgArgs: [command.username], msg: 'Account created, username is ' + command.username, domain: newuserdomain.id };
} else { } else {
event = { etype: 'user', userid: newuser._id, username: newusername, account: parent.CloneSafeUser(newuser), action: 'accountcreate', msg: 'Account created, email is ' + command.email.toLowerCase(), domain: newuserdomain.id }; event = { etype: 'user', userid: newuser._id, username: newusername, account: parent.CloneSafeUser(newuser), action: 'accountcreate', msgid: 65, msgArgs: [command.email.toLowerCase()], msg: 'Account created, email is ' + command.email.toLowerCase(), domain: newuserdomain.id };
} }
if (parent.db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to create the user. Another event will come. if (parent.db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to create the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
@ -1991,7 +1991,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var targets = ['*', 'server-users', user._id, chguser._id]; var targets = ['*', 'server-users', user._id, chguser._id];
if (allTargetGroups) { for (var i in allTargetGroups) { targets.push('server-users:' + i); } } if (allTargetGroups) { for (var i in allTargetGroups) { targets.push('server-users:' + i); } }
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(chguser), action: 'accountchange', msg: 'Account changed: ' + chguser.name, domain: edituserdomain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(chguser), action: 'accountchange', msgid: 66, msgArgs: [chguser.name], msg: 'Account changed: ' + chguser.name, domain: edituserdomain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} }
@ -2084,7 +2084,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify user change // Notify user change
var targets = ['*', 'server-users', user._id, xuser._id]; var targets = ['*', 'server-users', user._id, xuser._id];
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(xuser), action: 'accountchange', msg: 'User group membership changed: ' + xuser.name, domain: ugrpdomain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(xuser), action: 'accountchange', msgid: 67, msgArgs: [xuser.name], msg: 'User group membership changed: ' + xuser.name, domain: ugrpdomain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
//parent.parent.DispatchEvent(targets, obj, event); //parent.parent.DispatchEvent(targets, obj, event);
pendingDispatchEvents.push([targets, obj, event]); pendingDispatchEvents.push([targets, obj, event]);
@ -2097,7 +2097,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
db.Set(xmesh); db.Set(xmesh);
// Notify mesh change // Notify mesh change
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: xmesh._id, name: xmesh.name, mtype: xmesh.mtype, desc: xmesh.desc, action: 'meshchange', links: xmesh.links, msg: 'Added group ' + ugrp.name + ' to mesh ' + xmesh.name, domain: ugrpdomain.id, invite: mesh.invite }; var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: xmesh._id, name: xmesh.name, mtype: xmesh.mtype, desc: xmesh.desc, action: 'meshchange', links: xmesh.links, msgid: 68, msgArgs: [ugrp.name, xmesh.name], msg: 'Added user group ' + ugrp.name + ' to device group ' + xmesh.name, domain: ugrpdomain.id, invite: mesh.invite };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
//parent.parent.DispatchEvent(['*', xmesh._id, user._id], obj, event); //parent.parent.DispatchEvent(['*', xmesh._id, user._id], obj, event);
pendingDispatchEvents.push([parent.CreateMeshDispatchTargets(xmesh, [user._id]), obj, event]); pendingDispatchEvents.push([parent.CreateMeshDispatchTargets(xmesh, [user._id]), obj, event]);
@ -2112,7 +2112,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (db.changeStream == false) { parent.userGroups[ugrpid] = ugrp; } if (db.changeStream == false) { parent.userGroups[ugrpid] = ugrp; }
// Event the device group creation // Event the device group creation
var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: ugrpid, name: ugrp.name, desc: ugrp.desc, action: 'createusergroup', links: ugrp.links, msg: 'User group created: ' + ugrp.name, ugrpdomain: domain.id }; var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: ugrpid, name: ugrp.name, desc: ugrp.desc, action: 'createusergroup', links: ugrp.links, msgid: 69, msgArgv: [ugrp.name], msg: 'User group created: ' + ugrp.name, ugrpdomain: domain.id };
parent.parent.DispatchEvent(['*', ugrpid, user._id], obj, event); // Even if DB change stream is active, this event must be acted upon. parent.parent.DispatchEvent(['*', ugrpid, user._id], obj, event); // Even if DB change stream is active, this event must be acted upon.
// Event any pending events, these must be sent out after the group creation event is displatched. // Event any pending events, these must be sent out after the group creation event is displatched.
@ -2167,7 +2167,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify user change // Notify user change
var targets = ['*', 'server-users', user._id, xuser._id]; var targets = ['*', 'server-users', user._id, xuser._id];
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(xuser), action: 'accountchange', msg: 'User group membership changed: ' + xuser.name, delGroupDomain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(xuser), action: 'accountchange', msgid: 67, msgArgs: [xuser.name], msg: 'User group membership changed: ' + xuser.name, delGroupDomain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} }
@ -2178,7 +2178,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
db.Set(xmesh); db.Set(xmesh);
// Notify mesh change // Notify mesh change
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: xmesh._id, name: xmesh.name, mtype: xmesh.mtype, desc: xmesh.desc, action: 'meshchange', links: xmesh.links, msg: 'Removed group ' + group.name + ' from mesh ' + xmesh.name, domain: delGroupDomain.id }; var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: xmesh._id, name: xmesh.name, mtype: xmesh.mtype, desc: xmesh.desc, action: 'meshchange', links: xmesh.links, msgid: 70, msgArgs: [group.name, xmesh.name], msg: 'Removed user group ' + group.name + ' from device group ' + xmesh.name, domain: delGroupDomain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(xmesh, [user._id]), obj, event); parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(xmesh, [user._id]), obj, event);
} }
@ -2267,7 +2267,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify user change // Notify user change
var targets = ['*', 'server-users', user._id, chguser._id]; var targets = ['*', 'server-users', user._id, chguser._id];
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(chguser), action: 'accountchange', msg: 'User group membership changed: ' + chguser.name, domain: addUserDomain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(chguser), action: 'accountchange', msgid: 67, msgArgs: [chguser.name], msg: 'User group membership changed: ' + chguser.name, domain: addUserDomain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
@ -2285,7 +2285,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
db.Set(group); db.Set(group);
// Notify user group change // Notify user group change
var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: group._id, name: group.name, desc: group.desc, action: 'usergroupchange', links: group.links, msg: 'Added user ' + chguser.name + ' to user group ' + group.name, addUserDomain: domain.id }; var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: group._id, name: group.name, desc: group.desc, action: 'usergroupchange', links: group.links, msgid: 71, msgArgs: [chguser.name, group.name], msg: 'Added user ' + chguser.name + ' to user group ' + group.name, addUserDomain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user group. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user group. Another event will come.
parent.parent.DispatchEvent(['*', group._id, user._id, chguserid], obj, event); parent.parent.DispatchEvent(['*', group._id, user._id, chguserid], obj, event);
} }
@ -2334,7 +2334,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify user change // Notify user change
var targets = ['*', 'server-users', user._id, chguser._id]; var targets = ['*', 'server-users', user._id, chguser._id];
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(chguser), action: 'accountchange', msg: 'User group membership changed: ' + chguser.name, domain: removeUserDomain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(chguser), action: 'accountchange', msgid: 67, msgArgs: [chguser.name], msg: 'User group membership changed: ' + chguser.name, domain: removeUserDomain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
@ -2353,7 +2353,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify user group change // Notify user group change
if (change) { if (change) {
var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: group._id, name: group.name, desc: group.desc, action: 'usergroupchange', links: group.links, msg: 'Removed user ' + chguser.name + ' from user group ' + group.name, domain: removeUserDomain.id }; var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: group._id, name: group.name, desc: group.desc, action: 'usergroupchange', links: group.links, msgid: 72, msgArgs: [chguser.name, group.name], msg: 'Removed user ' + chguser.name + ' from user group ' + group.name, domain: removeUserDomain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user group. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user group. Another event will come.
parent.parent.DispatchEvent(['*', group._id, user._id, chguser._id], obj, event); parent.parent.DispatchEvent(['*', group._id, user._id, chguser._id], obj, event);
} }
@ -2395,7 +2395,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify change // Notify change
var targets = ['*', 'server-users', user._id]; var targets = ['*', 'server-users', user._id];
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } } if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msg: 'Mesh notification change.', domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msgid: 73, msg: 'Device group notification changed', domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
@ -2452,7 +2452,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var targets = ['*', 'server-users']; var targets = ['*', 'server-users'];
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } } if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msg: 'Account password changed: ' + user.name, domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msgid: 74, msgArgs: [user.name], msg: 'Account password changed: ' + user.name, domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
@ -2511,7 +2511,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
var targets = ['*', 'server-users', user._id, chguser._id]; var targets = ['*', 'server-users', user._id, chguser._id];
if (chguser.groups) { for (var i in chguser.groups) { targets.push('server-users:' + i); } } if (chguser.groups) { for (var i in chguser.groups) { targets.push('server-users:' + i); } }
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(chguser), action: 'accountchange', msg: 'Changed account credentials.', domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(chguser), action: 'accountchange', msgid: 75, msg: 'Changed account credentials', domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
@ -2674,7 +2674,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
// Event the device group creation // Event the device group creation
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: meshid, name: command.meshname, mtype: command.meshtype, desc: command.desc, action: 'createmesh', links: links, msg: 'Device group created: ' + command.meshname, domain: domain.id, creation: mesh.creation, creatorid: mesh.creatorid, creatorname: mesh.creatorname }; var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: meshid, name: command.meshname, mtype: command.meshtype, desc: command.desc, action: 'createmesh', links: links, msgid: 76, msgArgs: [command.meshname], msg: 'Device group created: ' + command.meshname, domain: domain.id, creation: mesh.creation, creatorid: mesh.creatorid, creatorname: mesh.creatorname };
parent.parent.DispatchEvent(['*', meshid, user._id], obj, event); // Even if DB change stream is active, this event must be acted upon. parent.parent.DispatchEvent(['*', meshid, user._id], obj, event); // Even if DB change stream is active, this event must be acted upon.
// Log in the auth log // Log in the auth log
@ -2721,7 +2721,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (err != null) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'deletemesh', responseid: command.responseid, result: err })); } catch (ex) { } } return; } if (err != null) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'deletemesh', responseid: command.responseid, result: err })); } catch (ex) { } } return; }
// Fire the removal event first, because after this, the event will not route // Fire the removal event first, because after this, the event will not route
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: command.meshid, name: command.meshname, action: 'deletemesh', msg: 'Device group deleted: ' + command.meshname, domain: domain.id }; var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: command.meshid, name: command.meshname, action: 'deletemesh', msgid: 77, msgArgs: [command.meshname], msg: 'Device group deleted: ' + command.meshname, domain: domain.id };
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(command.meshid), obj, event); // Even if DB change stream is active, this event need to be acted on. parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(command.meshid), obj, event); // Even if DB change stream is active, this event need to be acted on.
// Remove all user links to this mesh // Remove all user links to this mesh
@ -2735,7 +2735,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify user change // Notify user change
var targets = ['*', 'server-users', user._id, xuser._id]; var targets = ['*', 'server-users', user._id, xuser._id];
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(xuser), action: 'accountchange', msg: 'Device group membership changed: ' + xuser.name, domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(xuser), action: 'accountchange', msgid: 78, msgArgs: [xuser.name], msg: 'Device group membership changed: ' + xuser.name, domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} }
@ -2747,7 +2747,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify user group change // Notify user group change
var targets = ['*', 'server-ugroups', user._id, xgroup._id]; var targets = ['*', 'server-ugroups', user._id, xgroup._id];
var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: xgroup._id, name: xgroup.name, desc: xgroup.desc, action: 'usergroupchange', links: xgroup.links, msg: 'User group changed: ' + xgroup.name, domain: domain.id }; var event = { etype: 'ugrp', userid: user._id, username: user.name, ugrpid: xgroup._id, name: xgroup.name, desc: xgroup.desc, action: 'usergroupchange', links: xgroup.links, msgid: 79, msgArgs: [xgroup.name], msg: 'User group changed: ' + xgroup.name, domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} }
@ -2936,13 +2936,13 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (newuserid.startsWith('user/')) { if (newuserid.startsWith('user/')) {
// Notify user change // Notify user change
var targets = ['*', 'server-users', user._id, newuser._id]; var targets = ['*', 'server-users', user._id, newuser._id];
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(newuser), action: 'accountchange', msg: 'Device group membership changed: ' + newuser.name, domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(newuser), action: 'accountchange', msgid: 78, msgArgs: [newuser.name], msg: 'Device group membership changed: ' + newuser.name, domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} else if (newuserid.startsWith('ugrp/')) { } else if (newuserid.startsWith('ugrp/')) {
// Notify user group change // Notify user group change
var targets = ['*', 'server-ugroups', user._id, newuser._id]; var targets = ['*', 'server-ugroups', user._id, newuser._id];
var event = { etype: 'ugrp', username: user.name, ugrpid: newuser._id, name: newuser.name, desc: newuser.desc, action: 'usergroupchange', links: newuser.links, msg: 'User group changed: ' + newuser.name, domain: domain.id }; var event = { etype: 'ugrp', username: user.name, ugrpid: newuser._id, name: newuser.name, desc: newuser.desc, action: 'usergroupchange', links: newuser.links, msgid: 79, msgArgs: [newuser.name], msg: 'User group changed: ' + newuser.name, domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} }
@ -2952,12 +2952,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Remove userid from the mesh // Remove userid from the mesh
delete mesh.links[newuserid]; delete mesh.links[newuserid];
db.Set(mesh); db.Set(mesh);
event = { etype: 'mesh', username: newuser.name, userid: user._id, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: 'Removed user ' + newuser.name + ' from mesh ' + mesh.name, domain: domain.id, invite: mesh.invite }; event = { etype: 'mesh', username: newuser.name, userid: user._id, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: 'Removed user ' + newuser.name + ' from device group ' + mesh.name, domain: domain.id, invite: mesh.invite };
} else { } else {
// Add userid to the mesh // Add userid to the mesh
mesh.links[newuserid] = { name: newuser.name, rights: command.meshadmin }; mesh.links[newuserid] = { name: newuser.name, rights: command.meshadmin };
db.Set(mesh); db.Set(mesh);
event = { etype: 'mesh', username: newuser.name, userid: user._id, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: 'Added user ' + newuser.name + ' to mesh ' + mesh.name, domain: domain.id, invite: mesh.invite }; event = { etype: 'mesh', username: newuser.name, userid: user._id, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: 'Added user ' + newuser.name + ' to device group ' + mesh.name, domain: domain.id, invite: mesh.invite };
} }
// Notify mesh change // Notify mesh change
@ -3075,7 +3075,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify user change // Notify user change
var targets = ['*', 'server-users', newuserid]; var targets = ['*', 'server-users', newuserid];
var event = { etype: 'user', userid: user._id, username: user.name, action: 'accountchange', msg: (command.rights == 0) ? ('Removed user device rights for ' + newuser.name) : ('Changed user device rights for ' + newuser.name), domain: domain.id, account: parent.CloneSafeUser(newuser), nodeListChange: newuserid }; var event;
if (command.rights == 0) {
event = { etype: 'user', userid: user._id, username: user.name, action: 'accountchange', msgid: 81, msgArgs: [newuser.name], msg: 'Removed user device rights for ' + newuser.name, domain: domain.id, account: parent.CloneSafeUser(newuser), nodeListChange: newuserid };
} else {
event = { etype: 'user', userid: user._id, username: user.name, action: 'accountchange', msgid: 82, msgArgs: [newuser.name], msg: 'Changed user device rights for ' + newuser.name, domain: domain.id, account: parent.CloneSafeUser(newuser), nodeListChange: newuserid };
}
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} else if (newuserid.startsWith('ugrp/')) { } else if (newuserid.startsWith('ugrp/')) {
@ -3083,7 +3088,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify user group change // Notify user group change
var targets = ['*', 'server-ugroups', newuser._id]; var targets = ['*', 'server-ugroups', newuser._id];
var event = { etype: 'ugrp', username: user.name, ugrpid: newuser._id, name: newuser.name, action: 'usergroupchange', links: newuser.links, msg: 'User group changed: ' + newuser.name, domain: domain.id }; var event = { etype: 'ugrp', username: user.name, ugrpid: newuser._id, name: newuser.name, action: 'usergroupchange', links: newuser.links, msgid: 79, msgArgs: [newuser.name], msg: 'User group changed: ' + newuser.name, domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} }
@ -3096,7 +3101,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
db.Set(parent.cleanDevice(node)); db.Set(parent.cleanDevice(node));
// Event the node change // Event the node change
var event = { etype: 'node', userid: user._id, username: user.name, action: 'changenode', nodeid: node._id, domain: domain.id, msg: (command.rights == 0) ? ('Removed user device rights for ' + node.name) : ('Changed user device rights for ' + node.name), node: parent.CloneSafeNode(node) } var event;
if (command.rights == 0) {
event = { etype: 'node', userid: user._id, username: user.name, action: 'changenode', nodeid: node._id, domain: domain.id, msgid: 81, msgArgs: [node.name], msg: 'Removed user device rights for ' + node.name, node: parent.CloneSafeNode(node) }
} else {
event = { etype: 'node', userid: user._id, username: user.name, action: 'changenode', nodeid: node._id, domain: domain.id, msgid: 82, msgArgs: [node.name], msg: 'Changed user device rights for ' + node.name, node: parent.CloneSafeNode(node) }
}
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
parent.parent.DispatchEvent(dispatchTargets, obj, event); parent.parent.DispatchEvent(dispatchTargets, obj, event);
} }
@ -3172,13 +3182,13 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (deluserid.startsWith('user/')) { if (deluserid.startsWith('user/')) {
// Notify user change // Notify user change
var targets = ['*', 'server-users', user._id, deluser._id]; var targets = ['*', 'server-users', user._id, deluser._id];
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(deluser), action: 'accountchange', msg: 'Device group membership changed: ' + deluser.name, domain: xdomain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(deluser), action: 'accountchange', msgid: 78, msgArgs: [deluser.name], msg: 'Device group membership changed: ' + deluser.name, domain: xdomain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} else if (deluserid.startsWith('ugrp/')) { } else if (deluserid.startsWith('ugrp/')) {
// Notify user group change // Notify user group change
var targets = ['*', 'server-ugroups', user._id, deluser._id]; var targets = ['*', 'server-ugroups', user._id, deluser._id];
var event = { etype: 'ugrp', username: user.name, ugrpid: deluser._id, name: deluser.name, desc: deluser.desc, action: 'usergroupchange', links: deluser.links, msg: 'User group changed: ' + deluser.name, domain: xdomain.id }; var event = { etype: 'ugrp', username: user.name, ugrpid: deluser._id, name: deluser.name, desc: deluser.desc, action: 'usergroupchange', links: deluser.links, msgid: 79, msgArgs: [deluser.name], msg: 'User group changed: ' + deluser.name, domain: xdomain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} }
@ -3193,9 +3203,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify mesh change // Notify mesh change
var event; var event;
if (deluser != null) { if (deluser != null) {
event = { etype: 'mesh', username: user.name, userid: deluser.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: 'Removed user ' + deluser.name + ' from group ' + mesh.name, domain: xdomain.id, invite: mesh.invite }; event = { etype: 'mesh', username: user.name, userid: deluser.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msgid: 83, msgArgs: [deluser.name, mesh.name], msg: 'Removed user ' + deluser.name + ' from device group ' + mesh.name, domain: xdomain.id, invite: mesh.invite };
} else { } else {
event = { etype: 'mesh', username: user.name, userid: (deluserid.split('/')[2]), meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msg: 'Removed user ' + (deluserid.split('/')[2]) + ' from group ' + mesh.name, domain: xdomain.id, invite: mesh.invite }; event = { etype: 'mesh', username: user.name, userid: (deluserid.split('/')[2]), meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, action: 'meshchange', links: mesh.links, msgid: 83, msgArgs: [(deluserid.split('/')[2]), mesh.name], msg: 'Removed user ' + (deluserid.split('/')[2]) + ' from device group ' + mesh.name, domain: xdomain.id, invite: mesh.invite };
} }
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(mesh, [user._id, command.userid]), obj, event); parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(mesh, [user._id, command.userid]), obj, event);
if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'removemeshuser', responseid: command.responseid, result: 'ok' })); } catch (ex) { } } if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'removemeshuser', responseid: command.responseid, result: 'ok' })); } catch (ex) { } }
@ -3282,7 +3292,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
db.Set(device); db.Set(device);
// Event the new node // Event the new node
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(command.meshid, [nodeid]), obj, { etype: 'node', userid: user._id, username: user.name, action: 'addnode', node: parent.CloneSafeNode(device), msg: 'Added device ' + command.devicename + ' to mesh ' + mesh.name, domain: domain.id }); parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(command.meshid, [nodeid]), obj, { etype: 'node', userid: user._id, username: user.name, action: 'addnode', node: parent.CloneSafeNode(device), msgid: 84, msgArgs: [command.devicename, mesh.name], msg: 'Added device ' + command.devicename + ' to device group ' + mesh.name, domain: domain.id });
}); });
} }
break; break;
@ -3389,7 +3399,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Event the node change // Event the node change
var newMesh = parent.meshes[command.meshid]; var newMesh = parent.meshes[command.meshid];
var event = { etype: 'node', userid: user._id, username: user.name, action: 'nodemeshchange', nodeid: node._id, node: node, oldMeshId: oldMeshId, newMeshId: command.meshid, msg: 'Moved device ' + node.name + ' to group ' + newMesh.name, domain: domain.id }; var event = { etype: 'node', userid: user._id, username: user.name, action: 'nodemeshchange', nodeid: node._id, node: node, oldMeshId: oldMeshId, newMeshId: command.meshid, msgid: 85, msgArgs: [node.name, newMesh.name], msg: 'Moved device ' + node.name + ' to group ' + newMesh.name, domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(command.meshid, [oldMeshId, node._id]), obj, event); parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(command.meshid, [oldMeshId, node._id]), obj, event);
@ -3435,7 +3445,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify user change // Notify user change
var targets = ['*', 'server-users', cuser._id]; var targets = ['*', 'server-users', cuser._id];
var event = { etype: 'user', userid: cuser._id, username: cuser.name, action: 'accountchange', msg: 'Removed user device rights for ' + cuser.name, domain: domain.id, account: parent.CloneSafeUser(cuser) }; var event = { etype: 'user', userid: cuser._id, username: cuser.name, action: 'accountchange', msgid: 86, msgArgs: [cuser.name], msg: 'Removed user device rights for ' + cuser.name, domain: domain.id, account: parent.CloneSafeUser(cuser) };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} }
@ -3444,7 +3454,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
} }
// Event node deletion // Event node deletion
var event = { etype: 'node', userid: user._id, username: user.name, action: 'removenode', nodeid: node._id, msg: 'Removed device ' + node.name + ' from group ' + parent.meshes[node.meshid].name, domain: domain.id }; var event = { etype: 'node', userid: user._id, username: user.name, action: 'removenode', nodeid: node._id, msgid: 87, msgArgs: [node.name, parent.meshes[node.meshid].name], msg: 'Removed device ' + node.name + ' from device group ' + parent.meshes[node.meshid].name, domain: domain.id };
// TODO: We can't use the changeStream for node delete because we will not know the meshid the device was in. // TODO: We can't use the changeStream for node delete because we will not know the meshid the device was in.
//if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to remove the node. Another event will come. //if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to remove the node. Another event will come.
parent.parent.DispatchEvent(parent.CreateNodeDispatchTargets(node.meshid, node._id), obj, event); parent.parent.DispatchEvent(parent.CreateNodeDispatchTargets(node.meshid, node._id), obj, event);
@ -3963,7 +3973,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify change // Notify change
var targets = ['*', 'server-users', user._id]; var targets = ['*', 'server-users', user._id];
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } } if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msg: command.enabled ? "Enabled email two-factor authentication." :"Disabled email two-factor authentication.", domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msgid: command.enabled ? 88 : 89, msg: command.enabled ? "Enabled email two-factor authentication." :"Disabled email two-factor authentication.", domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
break; break;
@ -4005,7 +4015,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify change // Notify change
var targets = ['*', 'server-users', user._id]; var targets = ['*', 'server-users', user._id];
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } } if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msg: 'Added authentication application.', domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msgid: 90, msg: 'Added authentication application', domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} else { } else {
@ -4030,7 +4040,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify change // Notify change
var targets = ['*', 'server-users', user._id]; var targets = ['*', 'server-users', user._id];
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } } if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msg: 'Removed authentication application.', domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msgid: 91, msg: 'Removed authentication application', domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} else { } else {
@ -4045,7 +4055,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
const twoStepLoginSupported = ((parent.parent.config.settings.no2factorauth !== true) && (domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.nousers !== true)); const twoStepLoginSupported = ((parent.parent.config.settings.no2factorauth !== true) && (domain.auth != 'sspi') && (parent.parent.certificates.CommonName.indexOf('.') != -1) && (args.nousers !== true));
if (twoStepLoginSupported == false) break; if (twoStepLoginSupported == false) break;
var actionTaken = false, actionText = null; var actionTaken = false, actionText = null, actionId = 0;
if ((user.siteadmin == 0xFFFFFFFF) || ((user.siteadmin & 1024) == 0)) { // Don't allow generation of tokens if the account is settings locked if ((user.siteadmin == 0xFFFFFFFF) || ((user.siteadmin & 1024) == 0)) { // Don't allow generation of tokens if the account is settings locked
// Perform a sub-action // Perform a sub-action
if (command.subaction == 1) { // Generate a new set of tokens if (command.subaction == 1) { // Generate a new set of tokens
@ -4054,11 +4064,15 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
user.otpkeys = { keys: [] }; user.otpkeys = { keys: [] };
for (var i = 0; i < 10; i++) { user.otpkeys.keys[i] = { p: randomNumbers[i], u: true } } for (var i = 0; i < 10; i++) { user.otpkeys.keys[i] = { p: randomNumbers[i], u: true } }
actionTaken = true; actionTaken = true;
actionText = 'New 2FA backup codes generated.'; actionId = 92;
actionText = "New 2FA backup codes generated";
} else if (command.subaction == 2) { // Clear all tokens } else if (command.subaction == 2) { // Clear all tokens
actionTaken = (user.otpkeys != null); actionTaken = (user.otpkeys != null);
delete user.otpkeys; delete user.otpkeys;
if (actionTaken) { actionText = '2FA backup codes cleared.'; } if (actionTaken) {
actionId = 93;
actionText = "2FA backup codes cleared";
}
} }
// Save the changed user // Save the changed user
@ -4074,7 +4088,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
if (actionText != null) { if (actionText != null) {
var targets = ['*', 'server-users', user._id]; var targets = ['*', 'server-users', user._id];
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } } if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msg: actionText, domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msgid: actionId, msg: actionText, domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} }
@ -4112,7 +4126,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify change // Notify change
var targets = ['*', 'server-users', user._id]; var targets = ['*', 'server-users', user._id];
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } } if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msg: 'Removed security key.', domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msgid: 94, msg: 'Removed security key', domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
break; break;
@ -4162,7 +4176,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify change TODO: Should be done on all sessions/servers for this user. // Notify change TODO: Should be done on all sessions/servers for this user.
var targets = ['*', 'server-users', user._id]; var targets = ['*', 'server-users', user._id];
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } } if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msg: 'Added security key.', domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msgid: 95, msg: 'Added security key', domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} else { } else {
@ -4216,7 +4230,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Notify change // Notify change
var targets = ['*', 'server-users', user._id]; var targets = ['*', 'server-users', user._id];
if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } } if (user.groups) { for (var i in user.groups) { targets.push('server-users:' + i); } }
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msg: 'Added security key.', domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msgid: 95, msg: 'Added security key', domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(targets, obj, event); parent.parent.DispatchEvent(targets, obj, event);
} else { } else {
@ -4260,7 +4274,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
db.SetUser(user); db.SetUser(user);
// Event the change // Event the change
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msg: 'Verified phone number of user ' + EscapeHtml(user.name), domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msgid: 96, msgArgs: [user.name], msg: 'Verified phone number of user ' + EscapeHtml(user.name), domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(['*', 'server-users', user._id], obj, event); parent.parent.DispatchEvent(['*', 'server-users', user._id], obj, event);
@ -4275,7 +4289,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
db.SetUser(user); db.SetUser(user);
// Event the change // Event the change
var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msg: 'Removed phone number of user ' + EscapeHtml(user.name), domain: domain.id }; var event = { etype: 'user', userid: user._id, username: user.name, account: parent.CloneSafeUser(user), action: 'accountchange', msgid: 97, msgArgs: [user.name], msg: 'Removed phone number of user ' + EscapeHtml(user.name), domain: domain.id };
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come. if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
parent.parent.DispatchEvent(['*', 'server-users', user._id], obj, event); parent.parent.DispatchEvent(['*', 'server-users', user._id], obj, event);

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -10620,7 +10620,41 @@
60: "Removed user device rights for {0}", 60: "Removed user device rights for {0}",
61: "Changed user device rights for {0}", 61: "Changed user device rights for {0}",
62: "Removed user {0} from user group {1}", 62: "Removed user {0} from user group {1}",
63: "Account removed" 63: "Account removed",
64: "Account created, username is {0}",
65: "Account created, email is {0}",
66: "Account changed: {0}",
67: "User group membership changed: {0}",
68: "Added user group {0} to device group {1}",
69: "User group created: {0}",
70: "Removed user group {0} from device group {1}",
71: "Added user {0} to user group {1}",
72: "Removed user {0} from user group {1}",
73: "Device group notification changed",
74: "Account password changed: {0}",
75: "Changed account credentials",
76: "Device group created: {0}",
77: "Device group deleted: {0}",
78: "Device group membership changed: {0}",
79: "User group changed: {0}",
80: "Added user {0} to user group {1}",
81: "Removed user device rights for {0}",
82: "Changed user device rights for {0}",
83: "Removed user {0} from device group {1}",
84: "Added device {0} to device group {1}",
85: "Moved device {0} to group {1}",
86: "Removed user device rights for {0}",
87: "Removed device {0} from device group {1}",
88: "Enabled email two-factor authentication",
89: "Disabled email two-factor authentication",
90: "Added authentication application",
91: "Removed authentication application",
92: "New 2FA backup codes generated",
93: "2FA backup codes cleared",
94: "Removed security key",
95: "Added security key",
96: "Verified phone number of user {0}",
97: "Removed phone number of user {0}"
}; };
// Highlights the device being hovered // Highlights the device being hovered
@ -10654,7 +10688,7 @@
} else { } else {
msg = eventsMessageId[event.msgid]; msg = eventsMessageId[event.msgid];
if (event.msgArgs != null) { for (var i in event.msgArgs) { msg = msg.split('{' + i + '}').join(event.msgArgs[i]); } } if (event.msgArgs != null) { for (var i in event.msgArgs) { msg = msg.split('{' + i + '}').join(event.msgArgs[i]); } }
msg = 'x' + EscapeHtml(msg).split('(R)').join('&reg;'); msg = EscapeHtml(msg).split('(R)').join('&reg;');
} }
if (event.nodeid) { if (event.nodeid) {
var node = getNodeFromId(event.nodeid); var node = getNodeFromId(event.nodeid);