Merge pull request #2886 from Budibase/email-user-name

Using the user's name in emails sent out where possible
This commit is contained in:
Michael Drury 2021-10-05 11:59:14 +01:00 committed by GitHub
commit b120477572
3 changed files with 7 additions and 2 deletions

View File

@ -6,7 +6,7 @@
<tr> <tr>
<td class="content-cell"> <td class="content-cell">
<div class="f-fallback"> <div class="f-fallback">
<h1>Hi {{ email }},</h1> <h1>Hi {{#if name}}{{ name }}{{else}}{{ email }}{{/if}},</h1>
<p>You recently requested to reset your password for your {{ company }} account in your Budibase platform. Use the button below to reset it. <strong>This password reset is only valid for the next 24 hours.</strong></p> <p>You recently requested to reset your password for your {{ company }} account in your Budibase platform. Use the button below to reset it. <strong>This password reset is only valid for the next 24 hours.</strong></p>
<!-- Action --> <!-- Action -->
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation"> <table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0" role="presentation">

View File

@ -6,7 +6,7 @@
<tr> <tr>
<td class="content-cell"> <td class="content-cell">
<div class="f-fallback"> <div class="f-fallback">
<h1>Welcome, {{ email }}!</h1> <h1>Welcome, {{#if name}}{{ name }}{{else}}{{ email }}{{/if}}!</h1>
<p>Thanks for getting started with {{ company }}'s Budibase platform.</p> <p>Thanks for getting started with {{ company }}'s Budibase platform.</p>
<p>For reference, here's how to login:</p> <p>For reference, here's how to login:</p>
<table class="attributes" width="100%" cellpadding="0" cellspacing="0" role="presentation"> <table class="attributes" width="100%" cellpadding="0" cellspacing="0" role="presentation">

View File

@ -83,10 +83,15 @@ async function buildEmail(purpose, email, context, { user, contents } = {}) {
} }
base = base.contents base = base.contents
body = body.contents body = body.contents
let name = user ? user.name : undefined
if (user && !name && user.firstName) {
name = user.lastName ? `${user.firstName} ${user.lastName}` : user.firstName
}
context = { context = {
...context, ...context,
contents, contents,
email, email,
name,
user: user || {}, user: user || {},
} }