HTMLify user added email to admins

This commit is contained in:
Johannes Zellner
2017-01-17 15:34:50 +01:00
parent c932be77f8
commit 3845a8f02b
3 changed files with 45 additions and 7 deletions

View File

@@ -1,8 +1,8 @@
<%if (format === 'text') { %> <%if (format === 'text') { %>
Hi <%= cloudronName %> Admin, Dear <%= cloudronName %> Admin,
User with email <%= user.alternateEmail || user.email %> was added to <%= cloudronName %>. A new user with email <%= user.alternateEmail || user.email %> was added to <%= cloudronName %>.
<% if (inviteLink) { %> <% if (inviteLink) { %>
As requested, this user has not been sent an invitation email. As requested, this user has not been sent an invitation email.
@@ -12,7 +12,38 @@ To set a password and perform any configuration on behalf of the user, please us
<% } %> <% } %>
Powered by https://cloudron.io
<% } else { %> <% } else { %>
<center>
<img src="<%= cloudronAvatarUrl %>" width="128px" height="128px"/>
<h3>Dear <%= cloudronName %> Admin,</h3>
<p>
A new user with email <%= user.alternateEmail || user.email %> was added to <%= cloudronName %>.
</p>
<% if (inviteLink) { %>
<p>
As requested, this user has not been sent an invitation email.<br/>
<br/>
<a href="<%= inviteLink %>">Set a password and perform any configuration on behalf of the user</a>
</p>
<% } %> <% } %>
<br/>
<br/>
<div style="font-size: 10px; color: #333333; background: #ffffff;">
Powered by <a href="https://cloudron.io">Cloudron</a>.
</div>
</center>
<img src="https://analytics.cloudron.io/piwik.php?idsite=2&rec=1&e_c=CloudronEmail&e_a=userAdded" style="border:0" alt="" />
<% } %>

View File

@@ -1,6 +1,6 @@
<%if (format === 'text') { %> <%if (format === 'text') { %>
Hi <%= user.displayName || user.username || user.alternateEmail || user.email %>, Dear <%= user.displayName || user.username || user.alternateEmail || user.email %>,
Welcome to <%= cloudronName %>! Welcome to <%= cloudronName %>!
@@ -12,7 +12,7 @@ You are receiving this email because you were invited by <%= invitor.email %>.
<% } %> <% } %>
Powered by Cloudron.io Powered by https://cloudron.io
<% } else { %> <% } else { %>

View File

@@ -290,15 +290,22 @@ function userAdded(user, inviteSent) {
fqdn: config.fqdn(), fqdn: config.fqdn(),
user: user, user: user,
inviteLink: inviteSent ? null : config.adminOrigin() + '/api/v1/session/account/setup.html?reset_token=' + user.resetToken, inviteLink: inviteSent ? null : config.adminOrigin() + '/api/v1/session/account/setup.html?reset_token=' + user.resetToken,
format: 'text', cloudronName: cloudronName,
cloudronName: cloudronName cloudronAvatarUrl: config.adminOrigin() + '/api/v1/cloudron/avatar'
}; };
var templateDataText = JSON.parse(JSON.stringify(templateData));
templateDataText.format = 'text';
var templateDataHTML = JSON.parse(JSON.stringify(templateData));
templateDataHTML.format = 'html';
var mailOptions = { var mailOptions = {
from: mailConfig().from, from: mailConfig().from,
to: adminEmails.join(', '), to: adminEmails.join(', '),
subject: util.format('%s: user %s added', cloudronName, user.alternateEmail || user.email), subject: util.format('%s: user %s added', cloudronName, user.alternateEmail || user.email),
text: render('user_added.ejs', templateData) text: render('user_added.ejs', templateData),
html: render('user_added.ejs', templateDataHTML)
}; };
enqueue(mailOptions); enqueue(mailOptions);